• Resolved Santhosh veer

    (@worldfacts)


    After upgrading to 2.0 Service worker and Manifest File Not Generated

    – no Push Notifications

    PS: 1.9 Working well

    • This topic was modified 5 years, 11 months ago by Santhosh veer.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter Santhosh veer

    (@worldfacts)

    Tried this code
    No changes same 404 errors
    1.9 version works well no 404 errors

    Thread Starter Santhosh veer

    (@worldfacts)

    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…!

    • This reply was modified 5 years, 11 months ago by Santhosh veer.
    • This reply was modified 5 years, 11 months ago by Santhosh veer.

    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 ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘2.0 Service worker and Manifest File Not Generated’ is closed to new replies.