Version the brand images' URLs, so a new mark reaches returning visitors
The logo, favicons and app icons are served from public/img under fixed names with a browser cache of hours, and the service worker fetches them through that cache. After the mark changed on 2026-09-27, returning visitors kept the old cat until their copies expired, and the favicon and an installed app's icon hold on longer still. Every URL that names one now carries ?v=BRAND_V (src/lib/brand.ts, brandImage()): the header, sign-in, About, the mail empty state, the notification icons, index.html's favicon links, the manifest's icons and the service worker's shell and notification icons. Date-stamped, never a counter, for the sites' ASSET_V reason; the three static files carry the value written out, and the comment says to keep them in step.
This commit is contained in:
1 parent
2a30a32c79
commit
0adc402629
9 files changed
+49
-25
No files matched your search
+8
-6
@@ -18,7 +18,9 @@ const VERSION = "ihasmail-v2";
|
||||
* eventually would.
|
||||
*/
|
||||
const BASE = new URL("./", self.location).pathname.replace(/\/$/, "");
|
||||
const SHELL = [`${BASE}/manifest.webmanifest`, `${BASE}/img/logo.png`, `${BASE}/img/icon-192.png`, `${BASE}/favicon.ico`];
|
||||
// The brand images' version; the same value as BRAND_V in src/lib/brand.ts.
|
||||
const BRAND_V = "2026-09-27a";
|
||||
const SHELL = [`${BASE}/manifest.webmanifest`, `${BASE}/img/logo.png?v=${BRAND_V}`, `${BASE}/img/icon-192.png?v=${BRAND_V}`, `${BASE}/favicon.ico?v=${BRAND_V}`];
|
||||
|
||||
/*
|
||||
* Only the app page may be kept as the app page.
|
||||
@@ -482,7 +484,7 @@ self.addEventListener("push", (event) => {
|
||||
// or a payload too large to carry the message. Say something true
|
||||
// rather than inventing a sender.
|
||||
await self.registration.showNotification(strings.newMail, {
|
||||
icon: `${BASE}/img/icon-192.png`, badge: `${BASE}/img/favicon-64.png`, tag: "ihasmail-mail", data: { url: `${BASE}/mail` },
|
||||
icon: `${BASE}/img/icon-192.png?v=${BRAND_V}`, badge: `${BASE}/img/favicon-64.png?v=${BRAND_V}`, tag: "ihasmail-mail", data: { url: `${BASE}/mail` },
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -492,8 +494,8 @@ self.addEventListener("push", (event) => {
|
||||
const { title, body, preview } = textOf(email, strings);
|
||||
await self.registration.showNotification(title, {
|
||||
body: preview ? `${body}\n${preview}` : body,
|
||||
icon: `${BASE}/img/icon-192.png`,
|
||||
badge: `${BASE}/img/favicon-64.png`,
|
||||
icon: `${BASE}/img/icon-192.png?v=${BRAND_V}`,
|
||||
badge: `${BASE}/img/favicon-64.png?v=${BRAND_V}`,
|
||||
tag: `ihasmail-${email.id || body}`,
|
||||
// Only where there is a message to act on: a payload without an id can
|
||||
// be shown but not archived, and a button that cannot work should not
|
||||
@@ -537,8 +539,8 @@ async function runAction(action, data) {
|
||||
} catch {
|
||||
await self.registration.showNotification(data.title || "ihasmail", {
|
||||
body: data.failed || "Could not do that — open ihasmail and try again",
|
||||
icon: `${BASE}/img/icon-192.png`,
|
||||
badge: `${BASE}/img/favicon-64.png`,
|
||||
icon: `${BASE}/img/icon-192.png?v=${BRAND_V}`,
|
||||
badge: `${BASE}/img/favicon-64.png?v=${BRAND_V}`,
|
||||
tag: `ihasmail-failed-${id}`,
|
||||
data: { url: data.url },
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user