  We investigate for optimal photon absorption a quantum electrodynamical model
of an inhomogeneously-broadened spin ensemble coupled to a single-mode cavity.
We consider a one-photon input pulse and obtain a simple one-parameter form for
its optimal shape for absorption in the spin ensemble. Solutions to this
problem are developed without using perturbation theory concerning the spin
ensemble. Furthermore, we exploit the possibility of modulating the frequency
and coupling rate of the resonator. We show some optimal scenarios and
demonstrate the usefulness of our approach for the design of efficient quantum
memories. In particular, we find the optimal cooperativity for different
parameters and identify cases where absorption with a success probability
larger than $99\%$ is achieved.
