Deficiency of food resources in ontogeny is known to prolong an organism’s developmental time and affect body size in adulthood. Yet life‐history traits are plastic: an organism can increase its growth rate to compensate for a period of slow growth, a phenomenon known as ‘compensatory growth’. We tested whether larvae of the greater wax moth Galleria mellonella can accelerate their growth after a fast of 12, 24 or 72 h. We found that a subgroup of female larvae showed compensatory growth when starved for 12 h. Food deficiency lasting more than 12 h resulted in longer development and lower mass gain. Strength of encapsulation reactions against a foreign body inserted in haemocoel was the weakest in females that showed compensatory growth, whereas the strongest encapsulation was recorded in the males and females that fasted for 24 and 72 h. More specifically, we found sex‐biased immune reactions so that females had stronger encapsulation rates than males in one group that fasted for 72 h. Overall, rapidly growing females had a short larval development period and the shortest adult lifespan. These results suggest that highly dynamic trade‐offs between the environment, life‐history traits and sex lead to plasticity in developmental strategies/growth rates in the greater wax moth.