The focus of the present work is the acoustic oscillations exhibited by confined supersonic flow past a rectangular cavity of varying length-to-depth (LID) ratio, with a view to identify optimal dimensions for application in scramjet combustors. Experiments were conducted to study the acoustic oscillations induced by supersonic flow at a Mach number of 1.5 past a rectangular cavity of variable dimensions mounted on one wall of a rectangular duct. The effect of LID ratio of the cavity on the dominant acoustic modes registered on the wall of the duct opposite to the cavity is investigated. The range of LID ratio varied is 0.25-6.25. The dominant acoustic modes and the amplitudes are observed to be quite sensitive to LID ratio in the above range. Shifts in the dominant acoustic modes are observed predominantly for L/D approximate to 0.94 and L/D approximate to 1.5. The variation of the Strouhal number with LID ratio indicates a transition in the modal content in the 0.94 < L/D < 1.5 range. Further shifts in the dominant frequencies are observed in the 1.5 < LID < 5.0 range. Peak amplitudes occur at LID ratios of around 0.75 and 2.25, with over twice the magnitude at the former than at the latter condition. Time-averaged schlieren visualization indicates the presence of quasi-steady shocks at about 0.75 the length of the cavily for L/D <= 1 as opposed to being nearly at the trailing edge for higher LID ratio. Instantaneous phase-locked schlieren images show the quasi-steady shocks are due to the movement of vortices and compression waves along the length of the cavity. It is also observed that the number of vortices in the shear layer roll up along the length of the cavity increases corresponding to the mode shifts for cavities with LID > 1. Such distinct streamwise oscillations are also observed for cavities with L/D < 1, when the length is appreciable. The presence of higher modes in the acoustic oscillations is correlated with shocks produced at the lip of the cavity at a different frequency than the compression waves inside the cavity.