Compressible cavity flows exist widely in aeronautical vehicles. The cost of the computational fluid dynamics to solve compressible cavity flows is high. To address this issue, in this work, a novel reduced-order model (ROM) combining proper orthogonal decomposition (POD) with the long short-term memory (LSTM) neural network named LSTM-ROM for predicting the compressible cavity flows is proposed. First, POD is used to provide a low-dimensional subspace. Then, the LSTM neural network is designed to predict the POD coefficients with time evolution. The results show that the LSTM-ROM can accurately predict the POD coefficients for a long time and capture the shock wave structures at supersonic speed. The predicted density and normal velocity field are consistent with those simulated by direct numerical simulation (DNS). The calculation time of LSTM-ROM is almost one-seventh of that of DNS. By comparing the performance of LSTM-ROM with that of dynamic mode decomposition (DMD) and multilayer perceptron (MLP), it is found that the root mean square errors of density and normal velocity field predicted by LSTM-ROM are smaller than those predicted by DMD and MLP. In addition, the LSTM-ROM can accurately and efficiently predict the flows over cavities with different inclination angles at subsonic speed. Therefore, the LSTM-ROM is an accurate and efficient method for predicting the compressible cavity flows, which lays a foundation for other complex flows.