Jack mackerel Trachurus murphyi (JM) and chub mackerel Scomber japonicus (CM) are medium size pelagic fish predators and highly exploited resources. Here we investigated the spatiotemporal patterns of JM and CM diet composition using a large dataset of stomach samples collected from 1973 to 2013 along the Peruvian coast. In total 47,535 stomachs (18,377 CM and 29,158 JM) were analysed, of which 23,570 (12,476 CM and 11,094 JM) were non-empty. Results show that both species are opportunistic and present a trophic overlap. However, despite their smaller maximal size, CM consumed more fish than JM. Both diets presented high spatiotemporal variability. Spatially, the shelf break appears as a strong biogeographical barrier affecting prey species distribution and thus CM and JM diet. Opportunistic foragers are often considered as actual indicators of ecosystem changes; we show here that diet composition of CM and JM reveal ecosystem changes but is not always a good indicator of changes in prey biomass as prey accessibility and energy content can also play an important role. In addition we found that El Niño events have a surprisingly weak effect on stomach fullness and diet. Finally our results show that the classic paradigm of positive correlation between diversity and temperature is unlikely to occur in the Humboldt Current system where productivity seems to be the main driver. We show how energy content of forage species and the strength of the oxygen minimum zone most likely play an important role prey diversity and accessibility, and thus in fish foraging behaviour.