How does the electric field operator change inside an optical cavity In the free field, transverse electric field operator is given by the below expression;
$$d^{\bot}(R)=i \sum_{p,\lambda}\Big( \frac{\hbar cq}{2V\epsilon_{0}}\Big)^{1/2} \{e^{(\lambda)}(p)a^{(\lambda)}(p)e^{ip.R}-\bar{e}^{(\lambda)}(p)a^{\prime(\lambda)}(p)e^{-ip.R}\}
$$
here p=photon wave vector, q=corresponding wave number,$R$=position vector,$\lambda$=polarization vector,$a^{(\lambda)}(p),a^{\prime(\lambda)}(p)$=photon annihilation and creation operators. However my question is, how does this operator change when it comes to a cavity. Should I just add cavity modes to the above expressions? 
 A: since this expansion follows directly from maxwell's equations in Lorentz gauge, it should still hold identically for the cavity because the former also holds. However what changes are the boundary conditions so that the sum over momentum goes from being over $\mathbb{R}$ to being over $\mathbb{N}$ for $p = 2 \pi n\hbar/L$
A: In fact there is a difference, since the field per photon is stronger inside a cavity than in free space.  The first treatment I know of is that of Jaynes and Cummings, Proceedings of the IEEE, Vol 51, p 89 (1963).  This leads to an enhanced rate of spontaneous emission inside the cavity, called 'cavity enhancement', which is considered the cornerstone of Cavity Quantum Electrodynamics (CQED), a field for which Haroche and Wineland received the Nobel in Physics, in 2012.
Check out Eqs 14-20 in the Jaynes-Cummings reference.
A: 
Should I just add cavity modes to the above expressions?

Yes. Most naturally one can quantize the dielectric Maxwell equations and express the result in terms of modes. This approach was first worked out by Glauber&Lewenstein (1991). It is also called a "modes-of-the-universe"1 decomposition.
In effect this would result in replacing the plane wave function by a mode profile and the plane wave operator by a mode operator in the OP's expression for the electric field operator.
For real systems the modes of the universe can be hard to calculate, which is why there are a variety of other notions of modes. The modes-of-the-universe are just the easiest and formal best understood one.

1Ignore the suspiciously exaggerated name. This is a clean and simple quantization procedure.
