• Resolved alinnz

    (@alinnz)


    I want to set site assets caching into stale while revalidate and image caching into cache first. Is the following filter correct?

    add_filter(
    ‘wp_service_worker_theme_asset_caching’,
    function ( $config ) {
    $config[‘strategy’] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;

    add_filter(
    ‘wp_service_worker_plugin_asset_caching’,
    function ( $config ) {
    $config[‘strategy’] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;

    add_filter(
    ‘wp_service_worker_core_asset_caching’,
    function ( $config ) {
    $config[‘strategy’] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;

    add_filter(
    ‘wp_service_worker_uploaded_image_caching’,
    function ( $config ) {
    $config[‘strategy’] = WP_Service_Worker_Caching_Routes::STRATEGY_CACHE_FIRST;

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

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

    (@westonruter)

    That looks right, but here it is with better formatting:

    <?php
    add_filter(
    'wp_service_worker_theme_asset_caching',
    function ( $config ) {
    $config['strategy'] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;
    return $config;
    }
    );
    add_filter(
    'wp_service_worker_plugin_asset_caching',
    function ( $config ) {
    $config['strategy'] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;
    return $config;
    }
    );

    add_filter(
    'wp_service_worker_core_asset_caching',
    function ( $config ) {
    $config['strategy'] = WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE;
    return $config;
    }
    );

    add_filter(
    'wp_service_worker_uploaded_image_caching',
    function ( $config ) {
    $config['strategy'] = WP_Service_Worker_Caching_Routes::STRATEGY_CACHE_FIRST;
    return $config;
    }
    );
    Thread Starter alinnz

    (@alinnz)

    Thank you, Sir!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.