web: the muted text that was never muted, and the stylesheet fetched every time
Every text-[color:var(--ink)]/50, border-[color:var(--ink)]/10 and
bg-[color:var(--ink)]/5 in the templates compiled to nothing. Tailwind v3
cannot put an opacity on an arbitrary var() colour, so all 538 of them were
dropped from output.css without a word. Meta text rendered at full ink, card
borders fell back to Tailwind's default grey (bright white rings at night),
and the washes, backdrops and hover pills simply weren't there, on the news
site, the casino and the adventure pages alike.
The palette is now written once per phase and casino room as bare rgb
channels (--ink-rgb and friends), the plain vars are built from them, and
tailwind.config.js exposes ink, muted, accent, warn and card as real colours.
The classes are text-ink/80, border-ink/10, bg-accent/20 now, and they compile.
Restoring the intended opacities as-is would have traded flat for illegible:
ink at 50% measures 2.7 to 2.9:1 on the lit phases. So secondary text gets
its own colour, --muted, per phase and per casino room, taken as faint as it
can go while still clearing 4.5:1 on both the card and the page. Everything
that was ink at 35 to 70% is text-muted. The 20-30% ones are separators and
empty-cell dashes and stay faint.
The bg-theme-* chips carry white text everywhere they appear, and eight of
them measured 2.5 to 3.2:1. Same hues, taken just dark enough to pass (4.6 to
4.7:1). eu, lego and adventure already passed and are unchanged, and the
underline and border colours keep the old pastels since they carry no text.
Static files came out of the embedded FS with no Last-Modified, no ETag and
no Cache-Control, so every page view downloaded the stylesheet and every
script in full, and the service worker's "cheap 304" never happened. Each
file is hashed once now. Templates link through {{asset}}, which appends
?v=<hash>; a request naming the current hash is served immutable for a year,
and everything else gets the hash as its ETag and revalidates to a 304. The
service worker serves versioned URLs cache-first, drops older versions of the
same file as new ones land, and moves to cache v6.
This commit is contained in:
+34
-16
@@ -4,12 +4,13 @@
|
||||
//
|
||||
// Bump CACHE_VERSION whenever the precached shell assets change; activate()
|
||||
// drops every cache that doesn't match the current version.
|
||||
var CACHE_VERSION = "v5";
|
||||
var CACHE_VERSION = "v6";
|
||||
var SHELL_CACHE = "pete-shell-" + CACHE_VERSION;
|
||||
var RUNTIME_CACHE = "pete-runtime-" + CACHE_VERSION;
|
||||
|
||||
// App shell: the static assets every page needs. Versioned by URL content only
|
||||
// loosely, so we lean on network-first for HTML and cache-first for these.
|
||||
// App shell: the static assets every page needs, precached by bare URL so an
|
||||
// offline launch has something to fall back on. Pages ask for them with a
|
||||
// ?v=<hash> suffix; see the fetch handler for how the two meet.
|
||||
var SHELL_ASSETS = [
|
||||
"/static/css/output.css",
|
||||
"/static/js/prefs.js",
|
||||
@@ -117,25 +118,42 @@ self.addEventListener("fetch", function (event) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Static assets: network-first. Our asset URLs are NOT content-hashed
|
||||
// (/static/js/weather-gl.js stays the same URL across deploys), so a
|
||||
// cache-first strategy would pin whatever bytes were first cached and never
|
||||
// notice a redeployed file changed — leaving stale JS/CSS in place until the
|
||||
// CACHE_VERSION bump below. Go's FileServer sets ETag/Last-Modified, so an
|
||||
// online refetch is a cheap 304 when nothing changed. We still fill the cache
|
||||
// on every success and fall back to it when the network is unreachable, so
|
||||
// offline reading keeps the shell it needs.
|
||||
// Static assets. Pages link them as /static/...?v=<content hash> (the
|
||||
// {{asset}} template func), so a versioned URL names exactly one set of bytes
|
||||
// and is safe to serve cache-first: a redeploy that changes the file changes
|
||||
// the URL. When one is cached, older versions of the same file are dropped so
|
||||
// the shell cache doesn't grow by a copy per deploy.
|
||||
//
|
||||
// Anything requested by a bare URL (the precache list above, audio samples)
|
||||
// stays network-first; the server sends those no-cache with a content-hash
|
||||
// ETag, so the refetch is a 304 when nothing changed. Offline, either kind
|
||||
// falls back to whatever copy of that path is cached, whatever its version.
|
||||
if (url.pathname.indexOf("/static/") === 0) {
|
||||
event.respondWith(
|
||||
fetch(req).then(function (res) {
|
||||
var versioned = url.searchParams.has("v");
|
||||
var fromNetwork = function () {
|
||||
return fetch(req).then(function (res) {
|
||||
if (res && res.ok) {
|
||||
var copy = res.clone();
|
||||
caches.open(SHELL_CACHE).then(function (cache) { cache.put(req, copy); });
|
||||
caches.open(SHELL_CACHE).then(function (cache) {
|
||||
if (!versioned) return cache.put(req, copy);
|
||||
return cache.keys().then(function (keys) {
|
||||
keys.forEach(function (k) {
|
||||
var ku = new URL(k.url);
|
||||
if (ku.pathname === url.pathname && ku.search !== url.search) cache.delete(k);
|
||||
});
|
||||
return cache.put(req, copy);
|
||||
});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}).catch(function () {
|
||||
return caches.match(req);
|
||||
})
|
||||
return caches.match(req, { ignoreSearch: true });
|
||||
});
|
||||
};
|
||||
event.respondWith(
|
||||
versioned
|
||||
? caches.match(req).then(function (hit) { return hit || fromNetwork(); })
|
||||
: fromNetwork()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user