Nebula
Nebula copied to clipboard
Use stale-while-revalidate in Cache Control when available (🟧 awaiting Safari support)
https://www.chromestatus.com/feature/5050913014153216
Stale-While-Revalidate is coming as a Cache Control feature, so when that happens, consider updating the bundled .htaccess
file to use it.
For reference, here is the current method of caching files as of March 31, 2019:
#Cache files for certain lengths of time
#1 YEAR
<FilesMatch "\.(ico|pdf|flv|png|gif|swf|jpg|jpeg|svg|woff|mp3|css|php|html|js)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 30 Days
<FilesMatch "\.(png|gif|swf|jpg|jpeg|svg|woff|woff2|mp3|css|js)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 10 HOURS
<FilesMatch "\.(php|html)$">
Header set Cache-Control "max-age=36000, public"
</FilesMatch>
This is the new syntax: Cache-Control: max-age=1, stale-while-revalidate=59
The number is in seconds: Indicates the client will accept a stale response, while asynchronously checking in the background for a fresh one. The seconds value indicates how long the client will accept a stale response. Note that the time does not start at the time of the request itself, but, for example, after max-age has elapsed. See "Keeping things fresh with stale-while-revalidate" for more information.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
Waiting on Safari to support this before we can use it: https://caniuse.com/mdn-http_headers_cache-control_stale-while-revalidate
Still not supported in Safari...
July 2023 still waiting on Safari...