1. Caterpillars of the facultatively myrmecophilous butterfly Polyommatus icarus were reared on inflorescences, or foliage, of four natural hostplant species and on an artificial diet to study dietary effects on larval growth and secretory capacity. 2. Caterpillars achieved highest weights and relative growth rates when fed flowers of Medicago sativa, Lotus corniculatus or Melilotus officinalis. Larvae reared on Coronilla varia (flowers and leaves), foliage of M. sativa and on the artificial diet pupated at lower weights and achieved lower growth rates. 3. In standardized experiments with the ant species Lasius flavus, secretion rates from the dorsal nectar organ (DNO) were 2 times higher among flower-fed caterpillars than among foliage-fed siblings or caterpillars on the artificial diet. Larvae reared on C. varia flowers were superior to all other food treatments with respect to secretion rates. 4. High water content of larval diet, as in flowers, appears to be important for lycaenid caterpillars to achieve high secretion rates, whereas the correlation between myrmecophily and nutrient availability, as evidenced by growth rates, was less pronounced. 5. Using experimental data on larval growth and secretion rates, the lifetime volume of secretions from the DNO is estimated to range from 2 to 5 mu l in most food treatments. Only on C. varia flowers (5.5-8.7 mu l) and on M. sativa leaves (0.9-1.1 mu l) did the caterpillars deviate in their absolute investment in myrmecophily. 6. The estimated lifetime investment accounted for 1.6-5.5% of prepupal fresh weight in all food treatments except on C. varia flowers (7.8-12.3%).