• Resolved squarecandy

    (@squarecandy)


    Hello –

    I’m an advanced CloudFlare user and have defined our own set of Cache rules, and also have reviewed your implementation guide at https://gist.github.com/isaumya/af10e4855ac83156cc210b7148135fa2 and integrated some of the techniques there into our own rules. (Thanks for this guide, by the way!)

    The issue I’m having is that I have switch “Remove Cache Buster Query Parameter” to “Yes” but I’m still seeing it being added in some cases – for example when an Admin level user visits the Cart or Shop pages.

    Is there anything further I need to do to fully remove ?swcfpc=1 from the URL for all users in all cases? We’re completely managing the rules from the CF dashboard and don’t need this to show up anywhere.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter squarecandy

    (@squarecandy)

    I’ve done some additional testing and found a bit more about what’s going on:

    If you check the “Remove Cache Buster Query Parameter” this successfully marks the option as true in the options table. This basic test looks good and works:

    $test1 = new SW_CLOUDFLARE_PAGECACHE();
    $test2 = new SWCFPC_Cache_Controller( 'demo', $test1 );
    echo $test2->remove_cache_buster(); // returns 1;

    What it does do is successfully removes the inline JS code that modifies the links on the page. This take care of some but not all of the instances where the cachebuster appears. So the following things are now good:

    • existing links on the page don’t have cachebusters added
    • visiting pages like example.com/shop/ directly don’t add a cachebuster

    But a few circumstances cause it to reappear:

    • Anything that triggers a redirect causes it to be added. This could be as simple as leaving off the trailing slash – so example.com/shop/ is fine but example.com/shop causes a redirect to the version with the trailing slash and adds ?swcfpc=1
    • Anytime you submit a form instead of following a link, the cachebuster is also added. For example visiting example.com/cart/ directly it’s fine… but if you go to a product page and add a product to the cart – then ?swcfpc=1 is tacked on to the end when you get to the cart page after the form submission.
    Thread Starter squarecandy

    (@squarecandy)

    Ok! I found the solution:

    Just need to add if( $this->remove_cache_buster() ) return $location; near the top of function wp_redirect_filter in cache_controler.class.php

    This matches the logic in function inject_cache_buster_js_code but it’s just not included in the redirect filter.

    Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    Thanks for reporting this bug and the solution. I’ve added the fix. Can you please try downloading the patched version of the plugin from here and confirm that the issue has been fixed now?

    Thread Starter squarecandy

    (@squarecandy)

    Yup, that’s working for me!

    Thanks for the quick reply and for the awesome plugin. It’s very odd that the official Cloudflare WP plugin is so limited and actually causes more problems than it solves. Thanks for filling a need in the community with this great plugin!

    Plugin Contributor iSaumya

    (@isaumya)

    Thanks for confirming @squarecandy. ??

    Also super happy to hear that you are loving the plugin. These patches will be added to the upcoming update of the plugin.

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