hledger-web sends no caching headers on /static/*
$ curl -sI http://127.0.0.1:5000/static/js/jquery.min.js
HTTP/1.1 200 OK
Connection: close
Date: ...
Server: Warp/3.4.13.1
Content-Type: text/javascript
Vary: Accept-Encoding
Every page view refetches every asset: 9 files, ~112KB, per navigation.
Impact
Nothing on loopback. Serving the static files from memory, so they cost nothing at all,
leaves navigation time unchanged (p50 67ms either way) — the requests overlap with parsing
and executing the page, and the bytes are free locally.
Over a network it is the dominant cost. At 12 Mbps / 40ms RTT:
|
p50 |
p90 |
| as shipped |
284 ms |
316 ms |
| static files cached |
117 ms |
134 ms |
Cache invalidation
Long-lived caching needs the url to change when the file does, or an upgraded hledger keeps
serving the old javascript and css from cache. Content-hashed urls do that, but should not become
version numbers maintained by hand in templates.
The static files are already embedded at compile time, so the hash can come from the build.
Yesod's static subsite has support for this; worth checking what comes for free before
designing anything.
If hashed urls turn out to be awkward, ETag/Last-Modified alone still avoids re-sending
the bytes and cannot go stale.
Where
Hledger/Web/Settings/StaticFiles.hs builds the subsite with embed staticDir and generates
routes with publicFiles, giving unhashed paths like /static/js/jquery.min.js.
Independent of #2702 and #2705.
hledger-web sends no caching headers on
/static/*Every page view refetches every asset: 9 files, ~112KB, per navigation.
Impact
Nothing on loopback. Serving the static files from memory, so they cost nothing at all,
leaves navigation time unchanged (p50 67ms either way) — the requests overlap with parsing
and executing the page, and the bytes are free locally.
Over a network it is the dominant cost. At 12 Mbps / 40ms RTT:
Cache invalidation
Long-lived caching needs the url to change when the file does, or an upgraded hledger keeps
serving the old javascript and css from cache. Content-hashed urls do that, but should not become
version numbers maintained by hand in templates.
The static files are already embedded at compile time, so the hash can come from the build.
Yesod's static subsite has support for this; worth checking what comes for free before
designing anything.
If hashed urls turn out to be awkward,
ETag/Last-Modifiedalone still avoids re-sendingthe bytes and cannot go stale.
Where
Hledger/Web/Settings/StaticFiles.hsbuilds the subsite withembed staticDirand generatesroutes with
publicFiles, giving unhashed paths like/static/js/jquery.min.js.Independent of #2702 and #2705.