Limit caching for a specific page I'm working on a module, which includes a page that displays a select from a database table. The page content is getting cached for long periods, so is out of date for users.

What's the simplest way to set the cache timeout for this page to a shorter time (or even set that page to never cache)?

(As an aside, I intend to turn this table into an entity and integrate with Views later on, but I need an interim fix).
In case you know exactly when something changes (it is your own code doing it), you can also use a cache tag.

'tags' =&gt; ['my-tag'] within #cache and then when it changes, you invalidate it with \Drupal\Core\Cache\Cache::invalidateTags(['my-tag']).

The advantage is that your data is cached as long as possible and also immediately updated when it changes.

If you have constant changes, and that tag would actually result in shorter cache times, then setting a max-age might be more efficient, but that's usually not the case.