Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 2.45 KB

adr002-use-correct-caching-headers-for-all-files.md

File metadata and controls

39 lines (25 loc) · 2.45 KB

ADR002: Use Correct Caching Headers for all Files

Status: accepted

Context

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.

Decision

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.

Consequences

We will use the following configurations:

  1. 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.
  2. 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.