Cache invalidation strategies
Just like there are caching strategies, there are cache invalidation strategies you can employ to keep your cache from getting out of control. The PWA tickets application uses a maximum items strategy to control how many responses are cached, but there are other strategies you can use.
Unique hash names and long time-to-live values
A popular technique to make updating assets easier with long time to live values is using hash values in the file name. This is because a hash which is generated based on the file's contents means that the algorithm generates a relatively unique value.
The unique name creates a new URL for the asset and assigns a new Cache-Control value to the asset. This works well with style sheets, scripts and images, and other static resources.
MD5 hash values are the most common way to create these unique values. Node.js has a built-in crypto
module with MD5 hash capabilities:
function getHash(data) { var md5 = crypto.createHash('md5'); ...