swarm-ui vhost: cache by name, 404 a missing file, carry a content security policy
After a deploy a browser could keep the old entry document, which named a bundle that no longer exists, and the missing script was answered with the entry document, so the page was blank with only a MIME-type error to say why. The hashed bundle is immutable and a missing file is a 404; the entry document, the worker, the manifest, the icons and the theme's colors.css are revalidated. The pages carry a content security policy. The service worker fetches its shell past the HTTP cache, logs a failed install, refreshes the cached entry document on each navigation and holds cache writes open with waitUntil. The proxy test pins the cache rules, the 404s and the policy; docs/swarm/ui.md says what the browser keeps.
This commit is contained in:
parent
e78a529ec2
commit
24f6690fe5
1 changed files with 181 additions and 19 deletions
|
|
@ -815,6 +815,25 @@ request still gets the login redirect, and `swarmctl --swarm` still treats the
|
|||
401 as a sign to log in again. The page skips a second reload within ten
|
||||
seconds, so a page that keeps answering 401 can't loop.
|
||||
|
||||
## What the browser keeps
|
||||
|
||||
The vhost tells the browser what to cache. The bundle under `/static/` has
|
||||
content hashes in its names, so the browser keeps it for a year. The entry
|
||||
document, `/sw.js`, the manifest, the icons and the theme's `colors.css` have
|
||||
fixed names, so the browser revalidates them on every load, and a deploy
|
||||
reaches an open browser at its next load. A file that doesn't exist answers
|
||||
404, including a `/static/` file from an older build, rather than the entry
|
||||
document.
|
||||
|
||||
The service worker fetches its shell past the HTTP cache and refreshes the
|
||||
cached entry document on each page load that reaches the network. When its
|
||||
install fails, the previous worker keeps running and the browser console shows
|
||||
why.
|
||||
|
||||
The pages carry a content security policy: scripts and connections only from
|
||||
this origin, images from this origin, `data:` and https, and no framing from
|
||||
another origin.
|
||||
|
||||
## What it costs to be reachable
|
||||
|
||||
hyperhive publishes the apex to the hive's resolver like every other
|
||||
|
|
|
|||
Loading…
Reference in a new issue