First consider the classical case, the simplest optical resonant cavity is a rectangular cavity whose surface is an ideal conductor. The field inside the cavity can be described by Maxwell Equations.
The field is: $$E_x=A_1\cos\left(\frac{m\pi x}{L_1}\right)\sin\left(\frac{n\pi x}{L_2}\right)\sin\left(\frac{p\pi x}{L_3}\right)\cos\omega t $$ $$E_y=A_2\sin\left(\frac{m\pi x}{L_1}\right)\cos\left(\frac{n\pi x}{L_2}\right)\sin\left(\frac{p\pi x}{L_3}\right)\cos\omega t $$ $$E_z=A_3\sin\left(\frac{m\pi x}{L_1}\right)\sin\left(\frac{n\pi x}{L_2}\right)\cos\left(\frac{p\pi x}{L_3}\right)\cos\omega t $$ $$A_1\cdot\frac{m}{L_1}+A_2\cdot\frac{n}{L_2}+A_3\cdot\frac{p}{L_3}=0$$ $$ B_x,B_y,B_z\propto\sin\omega t,\ \ \omega=\frac{\pi}{\sqrt{\epsilon\mu}}\sqrt{\left(\frac{m}{L_1}\right)^2+\left(\frac{n}{L_2}\right)^2+\left(\frac{p}{L_3}\right)^2} $$ When $t=0$, if we change the refractive index (if we change $\sqrt{\epsilon\mu}$), we can easily notice that the field is still an eigenstate of the resonator, we only change its oscillation frequency.
So the question is, can it be put forward into quantum regime? In cavity QED, if the state is a 1-photon state in the cavity, if we change the refractive index inside the cavity, can we change the frequency of the photon?