The relativistic mirror (RM) is an interesting subject which introduced in the nonlinear regime of the laser–plasma interaction. Reflection of counter-propagating probe pulse from relativistic flying mirror has some excellent features, such as frequency up-shifting and compressing by a factor of 4γ2. In the high-intensity laser–plasma interaction, sometimes a sequence of RMs creates. For example, electron density cusps generate in the nonlinear laser wakefield generation or flying electron sheaths create in the blown-out regime of the laser foil interaction. Under these circumstances, the second counter-propagated seed (probe) pulse can be reflected back and forth between two or more successive RMs. This structure may be used as a relativistic cavity (RECA). Amplification and threshold conditions for the gain medium and pumping rate in the RECA are obtained, and it is shown that amplification can be started from background simultaneous emission (without seed pulse). A new feature of RECA is it's bidirectional (two frequencies) characteristic. Thereupon, the gain process can be implemented on the two different transitions in this bidirectional gain structure. In the RECA, driver pulse may be assembled as a pumping operation, and background plasma medium with high degree ionized substances is a good candidate for gain medium in the UV or X-ray regions. In this paper, we propose a new all-optical cavity for the generation of the ultrashort laser pulse in the UV or X-ray regions.