We investigate the influence of the electron-phonon interaction on the decay dynamics of a quantum dot coupled to an optical microcavity. We show that the electron-phonon interaction has important consequences on the dynamics, especially when the quantum dot and cavity are tuned out of resonance, in which case the phonons may add or remove energy leading to an effective nonresonant coupling between quantum dot and cavity. The system is investigated using two different theoretical approaches: (i) a second-order expansion in the bare phonon coupling constant, and (ii) an expansion in a polaron-photon coupling constant, arising from the polaron transformation which allows an accurate description at high temperatures. In the low-temperature regime, we find excellent agreement between the two approaches. An extensive study of the quantum dot decay dynamics is performed, where important parameter dependencies are covered. We find that in general the electron-phonon interaction gives rise to a greatly increased bandwidth of the coupling between quantum dot and cavity. At low temperature, an asymmetry in the quantum dot decay rate is observed, leading to a faster decay when the quantum dot has a larger energy than to the cavity. We explain this as due to the absence of phonon absorption processes. Furthermore, we derive approximate analytical expressions for the quantum dot decay rate, applicable when the cavity can be adiabatically eliminated. The expressions lead to a clear interpretation of the physics and emphasize the important role played by the effective phonon density, describing the availability of phonons for scattering, in quantum dot decay dynamics. Based on the analytical expressions, we present the parameter regimes where phonon effects are expected to be important. Also, we include all technical developments in appendixes.