I am looking for a way to search the cacheStorage. I think I can use a function like this to return boolean, but I need to know the cache version from the front end. Maybe it could be stored somewhere in the front end cache. I could hard code it for now, but it would break if the cache version is changed.
Currently I am setting up a method which looks something like this in my Vue component.
`async displayOfflineComponent( url ) {
// no need to display if offline
if ( navigator.online )
return false;
// i need a way to get this from the backend
const cacheName = ”;
const cacheStorage = await caches.open( cacheName );
const cachedResponse = await cacheStorage.match( url );
if ( ! cachedResponse || ! cachedResponse.ok )
return true;
return false;
}`
Do you have any other suggestions which I can accomplish this?