Skip to main content

Module ui_cache

Module ui_cache 

Source
Expand description

How the served web UI is cached by a browser. A headless server serves the built UI from a folder, and the package’s files carried one fixed modification date, no validator and no Cache-Control: a browser then kept the old shell (index.html) for weeks, and a revalidation by that date was answered “not modified” after the server was upgraded, so a normal reload kept showing the old version.

The rules, by file:

  • /assets/* (Vite names each by its content hash): cached for a year and immutable. private, because the server answers on the person’s own address only.
  • every other file (index.html, which also answers any path no file claims, early-boot.js, /fonts/* and /fontawesome/*, none of which carry a hash): no-cache, so the browser asks again each time, with an ETag of the file’s content, so a file that did not change costs a 304 and one that did is sent whole.
  • no file is ever dated: Last-Modified is dropped, and an If-Modified-Since is not heard, because a browser that cached an older server’s file holds only that date to ask with, and the answer to it must be the file.

Constants§

IMMUTABLE 🔒
MAX_HASHED_BYTES 🔒
The longest file given an ETag (it is read whole to hash it): the largest un-hashed file is a font.
REVALIDATE 🔒

Functions§

matches 🔒
Does an If-None-Match value name this tag (any of a list, or *; a weak tag counts as its strong form)?
ui_cache 🔒
Middleware for the served UI’s files; see the module’s rules.