Repository navigation
Description
GH Pages sends Cache-Control:max-age=600 header (and corresponding Expires in 10minutes).
http://www.webpagetest.org/performance_optimization.php?test=150216_4T_H0J&run=1&cached=0
Also it was served via Fastly CDN.
Heroku and RHcloud [http://www.webpagetest.org/result/150216_TV_HNP/, http://www.webpagetest.org/result/150216_CH_HP2/] also set 10 minutes.
So at least I'm not worse off...
Background reading: http://tomayko.com/writings/things-caches-do
I see 3 approaches:
- Longer fixed max-age. Not good when rolling out new version; in fact 10min can also cause breakage.
- ETag with hash of content. Still requires request but probably cheap with HTTP pipelining?
- Change URL when content changes (e.g. include git commit), so max-age can be set to infinity.
This is hard to do with dev/prod parity — if index.html from checkout works, then dynamic server must rewrite links? Also, unless every single file changes (which requires more extensive rewriting) this may end up caching less than stable URL + ETag.
Oh, should also read up cache manifests (or is that only for browser extensions?).
Activity
cben commentedon Feb 17, 2015
http://security.stackexchange.com/a/7008/31246 - set
Cache-control: publicto allow caching on HTTPScben commentedon Mar 2, 2015
Turns out there is some caching:
[http://www.webpagetest.org/result/150220_21_CGX/]
There are basically 2 kinds of caching:
max-ageand/orexpires) — the period when no request is needed at all — is not effective at 10min.etag— sending a request but hopefully getting a short "304 Not Modified" response. This works.Relevant headers in our response from RHcloud-hosted mathdown.net (on codemirror.js):
The last-modified time here is matches the file date (verified via ssh into rhcloud & heroku run):
The etag is generated based on the dev, ino, and last modified date. Stat results are cached.
[https://www.npmjs.com/package/st]
cben commentedon Mar 2, 2015
I actually want to get rid of max-age — for 10min after each deploy it may cause unpredictable bugs due to mixed versions.
The sane way to use max-age is to make it infinite and change URLs every time content changes. This is the most optimal approach but I don't see an easy way to make same it work with static files without rewriting relative paths in HTML and CSS.
There is one non-intrusive way of putting the whole static hierarchy under a subdir (named e.g.
static-G1THA5H/). Perhaps aided by `1cben commentedon Aug 7, 2015
During developement, changing a file still serves the old file for a short time (minute?), even with Shift+refresh.
cben commentedon Dec 17, 2022
As part of #172 I moved to Netlify, which does something sensible as a CDN, and I no longer care what exactly 👓