  We analyze the efficiency of the quantum Otto cycle applied to a
superconducting cavity. We consider its description in terms of a full quantum
scalar field in a one-dimensional cavity with a time dependent boundary
condition that can be externally controlled to perform and extract work
unitarily from the system. We study the performance of this machine when acting
as a heat engine as well as a refrigerator. It is shown that, in a
non-adiabatic regime, the efficiency of the quantum cycle is affected by the
dynamical Casimir effect, that induces a sort of quantum friction that
diminishes the efficiency. We also find regions of parameters where the effect
is so strong that the machine can no longer function as an engine since the
work that would be produced is completely consumed by the quantum friction.
However, this effect can be avoided for some particular temporal evolutions of
the boundary conditions that do not change the occupation number of the modes
in the cavity, leading to a highly improved efficiency.
