Closed karifrederiksen closed 2 years ago
Let's try it first by adding the Cache-Control
header in the Caddyfile for frontend requests, with the value max-age=259200, stale-while-revalidate
.
Did you add the header? It's not in /frontend/caddy/Caddyfile
on the dev branch.
No, I did not
I went ahead with setting Cache-Control response headers in Caddy with the following behavior:
/static/*
, the cache never expires, the assets are marked immutable/classes/*
, /doges/*
, /regions/*
, /specs/*
, and landing /landing/*
, assets are fresh for a day, afterwards we have another period of using stale-while-revalidate
for 6 days, to a total of 7 days caching time.Released in 1.0.0
Caddy has some default caching which leads to people having to force-clear their browser caches for every release.
Caching is fine for assets that include hashes in their names, such as the Javascript chunks. Caching images is probably fine for now since we never edit them - we can start hashing images once we start editing them.
index.html
on the other hand can't be hashed since it is referred to by name in the Caddyfile, and since we can't add a hash to its name and it's the root of our application, we must disable caching for it. Maybestale-while-revalidate
is appropriate though.