Support » Plugin: Super Progressive Web Apps » Add Extra URL for Caching

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Arun Basil Lal

    (@arunbasillal)

    Hello @iamkunaldesai

    Thanks for trying out our humble plugin.

    As of now, there is no easy way for this, but this is something we have in our roadmap already.

    I have added this ticket to our tracker and will file this as a feature request.

    Thanks again.

    Thanks.

    Plugin is Awesome.

    Keep it up.

    Humanly Yours

    Plugin Author Arun Basil Lal

    (@arunbasillal)

    Thanks for the kind words and all the feedback @iamkunaldesai 🙂

    Best regards.

    You can do it as I do, by adding filter to superpwa_sw_template hook. Like this:
    to you functions.php

    
    /**
     * Additional urls are passed from external resources to anonymous function
     */
    add_filter('superpwa_sw_template', function($template) use ($additional_urls) {
    global $urls_list;
    $urls_list = is_array($urls_list) ? $urls_list : [];
    $urls_list = array_merge($additional_urls, $urls_list);
    $pattern = '/(const filesToCache = \[.*)(\];)/';
    $replacement = sprintf('\\1%s\\2', count($urls_list) >= 2 ? ', \'' . implode('\',\'', $urls_list) . '\'' : ( count($urls_list) > 0 ? ', ' . $urls_list[0] : ''));
    return preg_replace($pattern, $replacement, $template);
    });
    

    You can play with internal code part in here:
    http://sandbox.onlinephpfunctions.com/code/a370634c6225b7062cecc263be93ede642e4bb11

    • This reply was modified 7 months, 1 week ago by  juslintek.
    Plugin Author Arun Basil Lal

    (@arunbasillal)

    Thanks @juslintek

    Glad to see someone making use of the filters that were just added already 🙂

    Thanks @juslintek for the code.

    Humanly Yours

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add Extra URL for Caching’ is closed to new replies.