The influence of age-driven investment on cooperation in spatial public goods games