• Resolved jimador

    (@jimador)


    Hi,

    There is something wrong in my app with the precaching setup.

    If I set precaching route as follows, with no versioning, the app won’t work offline because it looks for the versioned script when running offline.

    wp_register_service_worker_precaching_route('/wp-content/themes/astra-child/style.css',$args);

    Then I have to set precaching route as follows for the app to work properly offline:

    wp_register_service_worker_precaching_route('/wp-content/themes/astra-child/style.css?ver=1.0.0',$args);

    So, I have to include a version for every script file (.js,.css) precached. This means that I will have to edit child theme’s functions.php every time there is an update in any of these versioned scripts.

    Please advise on how to implement precaching best practices.

    Thanks in advance for your help.

Viewing 2 replies - 16 through 17 (of 17 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    The plugin I shared above is only for stylesheets, not scripts. So that is why scripts are not being precached. You can adapt it for precaching scripts as well.

    Thread Starter jimador

    (@jimador)

    Hi Weston,

    Our progressive web app is finally working fine offline. The solution, in addition to the implementation of the scripts you provided, is to precache all versioned files as follows:

    wp_register_service_worker_precaching_route('/wp-content/themes/astra/assets/js/minified/style.min.js?ver=2.0.1');

    You have to include the version number at the end of the URL exactly as it appears in the HTML code of your app pages.

    Thanks again for your professional support.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Precaching Best Practices’ is closed to new replies.