  The piston problem, i.e. the dynamics in a uniform gas at rest under the
action of a moving piston is fundamental problem of physics and a canonical
case study in shock wave physics. We investigate theoretically and
experimentally the analogous problem for a photon fluid, which turns out to be
strongly influenced by the dispersive character of the problem. The experiment
makes use of a fiber optics setup where an all-optically controlled quasi
instantaneous change of frequency of the input light mimics the piston action.
We show that the flow exhibits phase transitions which involve cross-over from
regimes characterized by 2-shocks (pushing piston) to 2-rarefaction waves
(retracting piston), with the appearance of cavitating states at critical
amplitudes of the jump. Importantly, the appearance of vacuum points into the
2-shock marks the transition to a regime which is unique to the photon fluid.
Our observations allow for the extensive and quantitative test of the state of
the art description of the dispersive Riemann problem, i.e. Whitham modulation
theory, applied to the universal defocusing nonlinear Schr\"odinger equation.
