Depth of the mine
Miners can utilise the full thickness of the leaf, or limit themselves to just one of the layers of a leaf. This has everything to do with leaf anatomy.
The illustration below shows a transverse section though a typical leaf, that of Beech (after Strasburger, 1958). From the top down one sees the upper epidermis, the palissade parenchyma, the sponge parenchyma and the lower epidermmis. The cells of the epidermis do not contain chlorophyll grains; they are abundant in the palissade parechyma, much less so in the sponge parenchyma. The cells of the palissade parenchyma are squeezed toghether like basalt columns; in other plant species the palissade parenchyma may consist of two or three layers. Photosynthesis takes place mainly in this part of the leaf. For this reason, and also because the cells are so densely packed, this is the most nutritious layer of the leaf. (Not all plant leaves follow this scheme; in particular leaves of ferns and grasses have a different anatomy.)
Upper-surface mines are limited to the palissade parenchyma, while lower-surface mines occupy to the sponge parenchyma. There are also species where the larva lives only in the epidermis, either throughout the entire larval life, or only in a few first instars.
The drawing also contains a section through a thin vein, containing a group of small, thick-walled cells. This explains with veins, and especially tjhe midrib and thick side veins, are a formidable barrier for the mining larva.
section through a Beech leaf
Larvae of sawflies, beetles and most moth families eat all the parenchyma (sawflies and beetles sometimes a bit sloppily). In the most important mining fly family, the Agromyzidae, situation is more complicated. Their larvae, with great precision, feed on either the palissade, or the sponge parenchyma (or part or their laral life the one, subsequently the other). There are also species that mine the upper or lower epidermis; mostly only when very young, a few species untill pupation.