Status: accepted
Caching is a key feature in HTTP. But caching could also potentially lead to stale content if the wrong files are cached. We want to make sure that all users receive a newly deployed widget version as soon as possible. This should not only work for new version updates, but also for reconfigurations (ex: new environment variables, updated translations) of the same version.
We will enable caching for all files that have a unique name (ex: a hash in a name) and will disable caching for all files that are not unique. Caching should only be disabled for files that are reasonably small.
We will use the following configurations:
Cache-Control "public, max-age=0, must-revalidate"
:index.html
: should never be cached because it is the entrypoint of the applications.locales/*
: locales are not uniquely named between versions and might be updated during a deployment.
Cache-Control \"public, max-age=3600\"
:static/*
: all CSS, JS, and media files are bundled with a hash in the filename. Files with the same name will always have the same content and can be safely cached.
The setting 1. will still order the browser to use features such as If-Match
or If-Modified-Since
to save bandwidth.
In fact, the browser will still cache the result, but it will always ask the server if the cached version is still up-to-date before presenting it to the user.