/* * [ Caution ] * Since this module is being used by a service worker, be very careful about adding imports or using functions for browsers. */ /** * The names of the worker's caches. The precache keeps one name across releases: each file in it carries its own * revision, so a new release fetches only the files that changed. With the version in its name, every release began * an empty cache and every person fetched the whole app again. The runtime cache holds files fetched as they are * read, with no revision of their own - it is kept per version, so a release reads them again. */ export function cacheNameDetails(appName: string, appVersion: string) { return { prefix: appName, runtime: `runtime-${appVersion}` } } /** The caches a newly active worker keeps; any other is a former version's and is deleted. */ export function cachesToKeep(workboxNames: Record, own: string[]) { return [...Object.values(workboxNames), ...own] }