Support » Plugin: Super Progressive Web Apps » Caching problems

  • Resolved paulfedorov

    (@paulfedorov)


    Hi!
    First of all – thanks for the great plugin. It really is a must have for 99% of sites as it is. Unfortunaltely, we are from 1% πŸ™‚

    We use REST API + vue.js components for frontend and it seems that Super PWA plugin prevents us from always getting fresh data from REST endpoint. Now I see that it should use Network Only strategy, but for some reason it doesn’t. Same goes for page content. As seen on screenshot here, whole page is loaded from ServiceWorker cache – https://monosnap.com/file/SMeDNd7FXphsy4FnKYV62el1PImP4p, and not from server. Thus multiple bugs and issues when users see each other’s private content (game balance, for example).

    I’m talking about user experience with PC browsers, not a PWA version.

    How can we prevent website from serving data from service worker cache?

    • This topic was modified 10 months ago by paulfedorov.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jose Varghese πŸš€

    (@josevarghese)

    Hi there,

    Good day to you and sorry for delay in responding quickly. As I haven’t yet worked on Vue.js, I’m not sure how it works over it, as you are using REST API mostly the contents will be served at the Service Worker from /wp-json/

    Can you please exclude the wp-json from service worker caching by copying the below code into functions.php

    /**
     * Exclude wp-json from SuperPWA cache
     * 
     * @link https://superpwa.com/codex/superpwa_sw_never_cache_urls/
     */
    function superpwa_exclude_from_cache( $superpwa_sw_never_cache_urls ) {
    	return $superpwa_sw_never_cache_urls . ',/\/wp-json/;
    }
    add_filter( 'superpwa_sw_never_cache_urls', 'superpwa_exclude_from_cache' );

    After that clear the browsing data and reactivate our plugin at to regenerate the Service Worker. Most probably it will help you.

    Don’t forget to clear the cache, if you are using any CDN or caching plugins.

    Looking forward.

    Plugin Author Jose Varghese πŸš€

    (@josevarghese)

    Slight correction over the code shared:

    /**
     * Exclude wp-json from SuperPWA cache
     * 
     * @link https://superpwa.com/codex/superpwa_sw_never_cache_urls/
     */
    function superpwa_exclude_from_cache( $superpwa_sw_never_cache_urls ) {
    	return $superpwa_sw_never_cache_urls . ',/\/wp-json/';
    }
    add_filter( 'superpwa_sw_never_cache_urls', 'superpwa_exclude_from_cache' );
    

    I missed a ' within it. πŸ™‚

    Plugin Author Jose Varghese πŸš€

    (@josevarghese)

    Closing this thread due to lack of response. You are always welcome to reopen the thread, if you feel my response didn’t help.

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