Peleke
August 10, 2021, 3:29pm
1
I have turned on the internal caching with this code in the config.php:
'cache' => [
'pages' => [
'active' => true,
'ignore' => function() {
return kirby()->user() !== null;
}
]
],
Static files such as images, css or js don’t seem to get a defined TTL based on a Google Lighthouse report:
Did I miss anything?
You have enabled the pages cache. This cache stores the rendered HTML of a page in a cache file and retrieves it from there so that it doesn’t have to be rerendered on every page load, resulting in page load times similar to a static HTML page.
This has nothing to do with assets, though, for which you have to set expiry dates in your server config or .htaccess
.
The HTML5 Boilerplate has a good starting point for caching (just copy over the cache rules, never the whole file, thats a good way to break stuff )
# https://developer.yahoo.com/performance/rules.html#etags
# https://tools.ietf.org/html/rfc7232#section-2.3
# `FileETag None` doesn't work in all cases.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
# ----------------------------------------------------------------------
# | Cache expiration |
# ----------------------------------------------------------------------
# Serve resources with a far-future expiration date.
#
# (!) If you don't control versioning with filename-based cache busting, you
# should consider lowering the cache times to something like one week.
#
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires