Generating a precache manifest for service workers I'm thinking of using Google's Workbox to pre-cache a bunch of files, and I've been scratching my head as to how to generate unique hashes for files when they change. Something like this:

 workbox.precaching.precacheAndRoute([
    { 
      url: '/',
      revision: '383676',
    },
    { 
      url: '/about',
      revision: 213142,
    },
    { 
      town: '/location',
      revision: 742125,
    },
  ]);


Ideally the revision number would change when the entry or related entries included in the page are changed/saved. I got this working but I'm not sure how to get related content to clear the cache:

// service-worker.js

{%- cache using key 'abc' -%}
    { 
      url: {{ craft.entries.id(64).one.uri }},
      revision: {{ random(100000, 999999) }},
    },
{%- endcache -%}


This seems to work when said entry is saved, but I'm not sure how to deal with a related entry being saved. I'm also not sure this is the most performant way to go.
So you shouldn't try to come up with a hashed file naming scheme for busting the cache; instead use one of Workbox's Strategies -- I think a great pattern for what you're trying to do is Stale While Revalidate

TL;DR Workbox has strategies for doing what you're trying to do.