• Resolved stoi2m1

    (@stoi2m1)


    I am using Vue as my fontend and using the WP API to obtain all of my data.

    How can I detect if content has been cached so I can display an “offline content not cached” message for non-cached content?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Magazine3

    (@magazine3)

    For this, which data needs in wp api. if you confirm it, so that we can make it.

    Thread Starter stoi2m1

    (@stoi2m1)

    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?

    Plugin Author Magazine3

    (@magazine3)

    We have stored the latest version in settings Via the below codes we get the cached version in the front end.

    $settings = pwaforwp_defaultSettings();
    $cacheVersion = $settings[‘force_update_sw_setting’];

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Detecting Cache Content’ is closed to new replies.