The magnetohydrodynamic response of the magnetospheric cavity to changes in solar wind pressure