Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

service worker: static files hashes #527

Closed
laurentpayot opened this issue Dec 4, 2018 · 2 comments
Closed

service worker: static files hashes #527

laurentpayot opened this issue Dec 4, 2018 · 2 comments

Comments

@laurentpayot
Copy link

laurentpayot commented Dec 4, 2018

Currently we can get files (an array of everything in the static directory) by doing so:

import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';

Then the template service worker puts these static files directly in a timestamp-named cache.
But to avoid reloading all my static files (especially my CSS framework in global.css) when a js file is updated, hashes of the static files are needed to detect when they are really modified.

Is it possible to modify files or to add an hashes named export to get an object like below?

export const hashes = {
	"global.css": "d739dfc3",
	"img/my-logo-192.png": "76dd89df",
	"img/my-logo-32.png": "39ad9914",
	"img/my-logo-512.png": "7a435e16",
	"img/my-logo.svg": "17225699",
	"manifest.json": "5cdfe09c"
};

It would really save unneeded reloads, meaning energy, and of course make the world a better place 😉

@benmccann
Copy link
Member

Rather than making a separate map, can we just put the hashes in the filenames? That will allow the files to be cached by CDNs.

I raised an issue in the template to add hashes to the filenames and provided the code to do so there. If I don't hear any objections I'll send it as a PR.

@benmccann
Copy link
Member

Closing this since sveltejs/sapper-template#248 was merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants