• Hi there!

    I’m one of the developers behind Nelio A/B Testing, a split testing solution for WordPress. We’re interested in improving our compatibility with Breeze Cache and there’s a couple of things that I don’t know how to tackle. I don’t even know if they’re possible and/or they’ll ever be.

    1. By default, our plugin loads alternative content by appending an extra query arg in a tested URL via a JavaScript redirection. That is, if a visitor lands on https://example.com/tested-page/, our plugin will redirect them to https://example.com/tested-page/?nab=X, where X is the variant they’re supposed to see (0 is variant A, 1 is variant B, etc).

    I looked at Breeze’s settings and I noticed there’s an option named Cache Query Strings. If I add nab there, (I think) Breeze behaves as I expected it to — that is, it properly caches each variant.

    Is there a way to add that nab query arg in the list of Cache Query Strings via a filter? This way, users of Nelio A/B Testing and Breeze wouldn’t need to add that extra argument in their URLs — it would work out of the box.

    2. We’re currently working on a new version of the plugin where, instead of loading alternative content based on the query arg, a user might decide to load alternative content based on the value of a visitor’s cookie. Are there any filters for that? In particular, I’d like to know:

    1. How do we (plugin developers) specify the name of that cookie?
    2. What should we do if a visitor requests a page and they don’t have the cookie yet? Is there a way to tell Breeze to skip cache if the cookie doesn’t exist and let WordPress run so that it can (a) generate the cookie and (b) serve the appropriate variant?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author owaisalam

    (@owaisalam)

    First of all, thank you for presenting such an intriguing scenario.

    Yes, you’ve grasped the concept accurately regarding the Cache Query String option. When you input any string, it caches the entire variant of it.

    Regarding the additional options you’ve inquired about, we’ll include them as feedback for our feature development list. While we aren’t currently offering them, rest assured they will be available in our upcoming releases.

    Thread Starter David Aguilera

    (@davilera)

    Thanks for your prompt response.

    For what it’s worth, here’s how other plugins (like WPRocket, for example) deal with (2).

    1. There’s a filter to specify which cookies contribute to dynamic caching (rocket_cache_dynamic_cookies). When set, WPRocket “creates a cache file for each value of a specified cookie.” That’s pretty much the same than what you’re already doing with Cache Query Strings.
    2. There’s another filter named rocket_cache_mandatory_cookies that “prevents caching until the specified cookie is set.” In other words, if a visitor lands on the site and they don’t have the cookie yet, all cached content is skipped and WordPress runs as it’s supposed to. This is great, because it means WordPress can generate the cookie for subsequent requests and can serve the appropriate content given that newly generated cookie.

    Another option to create the cookie for the first time (if you don’t want to bypass the cache and let WordPress run) would be to offer an extension mechanism in your plugin using PHP code. Something like, one drops a PHP file in a folder defined by you with some code to set the missing $_COOKIE in PHP. Then, Breeze would only need to read all the files in that folder and run them (with all the safety measures you deem necessary, of course).

    As far as I can tell, the only (complex) bit that’d be missing in your system would be this second filter/mechanism to set the cookie for the first time.

    Anyhow, thanks again for your time and I hope these ideas help you to improve your awesome plugin!

    Plugin Author owaisalam

    (@owaisalam)

    Thank you so much for your explanation; it will be very helpful for implementing the scenario in our plugin. We would greatly appreciate any further feedback to help us improve our plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Caching Filters for Plugin Developers’ is closed to new replies.