Hi Santhosh,
Good day to you. Can you please share some more details for the below queries:
1) Are you using any Security plugins over the website?
2) Is it a multisite or single site?
Looking forward.
Hello Santhosh,
Thank you for opening a separate ticket, that helps.
In your case, the 404 response is from the web server and not from WordPress, so I think it’s the cache plugin that is causing this.
Can you add the following to the functions.php
of your active theme:
/**
* Cache busting for SuperPWA manifest.
*
* @link https://superpwa.com/codex/superpwa_wp_head_tags/
*/
function superpwa_helper_cache_busting_manifest( $tags ) {
// Add ?nocache query string to manifest for cache busting.
$tags = preg_replace( '/<link rel="manifest" href="(.+)">/', '<link rel="manifest" href="$1?nocache">', $tags );
return $tags;
}
add_filter( 'superpwa_wp_head_tags', 'superpwa_helper_cache_busting_manifest' );
/**
* Register service worker with cache busting query string.
*
* @link https://github.com/SuperPWA/Super-Progressive-Web-Apps/blob/c3eafd27e207b52e3f1f83de392eeec0ecee1109/public/sw.php#L217-L232
*/
function superpwa_helper_register_sw() {
wp_enqueue_script( 'superpwa-register-sw', SUPERPWA_PATH_SRC . 'public/js/register-sw.js', array(), null, true );
wp_localize_script( 'superpwa-register-sw', 'superpwa_sw', array(
'url' => parse_url( superpwa_sw( 'src' ), PHP_URL_PATH ) . '?nocache',
)
);
}
remove_action( 'wp_enqueue_scripts', 'superpwa_register_sw' );
add_action( 'wp_enqueue_scripts', 'superpwa_helper_register_sw' );
Once that is added, clear the cache. Please let me know how it goes.
Tried this code
No changes same 404 errors
1.9 version works well no 404 errors
It’s working After I prevent SuperPWA Files from caching on w3Total Cache plugin
– Performance > Browser Cache > General (section)
Tick the Option
Do not process 404 errors for static objects with WordPress
– Next, add this Below Rule on the textBox under the Option we tick
robots\.txt
superpwa-manifest\.json
superpwa-sw\.js
sitemap(_index)?\.xml(\.gz)?
[a-z0-9_\-]*sitemap[a-z0-9_\-]*\.(xml|xsl|html)(\.gz)?
([a-z0-9_\-]*?)sitemap([a-z0-9_\-]*)?\.xml
Clear cache Done…!
Perfect!
When I was checking your service worker and manifest earlier, adding the query string ?nocache worked and that is why I suggested the code.
Glad you figured it out and thanks for reporting back the solution. Learned something new about W3TC as well 🙂