codewithkyle / asset-manager

A simple build tool for managing your Service Worker resource caches.
https://www.npmjs.com/package/@codewithkyle/asset-manager
MIT License
0 stars 0 forks source link

Add timestamp #1

Closed codewithkyle closed 3 years ago

codewithkyle commented 3 years ago

When generating the md5 hash for the manifest version include a timestamp.

var name = `${allFiles.length}-${totalSize}-${new Date().getTime()}`;

Why?

Minor CSS changes don't always register as actual changes. For example, changing the padding of an element from 1rem to 2rem returns the same total size so the service worker doesn't know that the cache needs to be cleared. The downside to adding a timestamp is that every deployment will trigger a full cache clear when using an automated deployment pipeline.