How do I programmatically set cache age?
This is all done from the render array itself.  The nitty gritty details are documented in Cacheability of render arrays.

In your case, you need to do something like

return [
  '#markup' =&gt; $this-&gt;t($pageContent),
  '#cache' =&gt; [
    'max-age' =&gt; 86400, // one day in seconds
  ],
];


This uses the #cache entry for the render array, and sets the max-age to be one day.  This is where you would also add in your cache contexts.

As a side note, try to avoid using '#markup'.  Use themeable elements, either though code or Twig.