Caching Filters for Plugin Developers
-
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 LiteSpeed Cache and, in particular, its dynamic caching capabilities.
In its current form, 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 tohttps://example.com/tested-page/?nab=X
, whereX
is the variant they’re supposed to see (0 is variant A, 1 is variant B, etc).We’re currently working on a new version of the plugin where, instead of loading alternative content based on the query arg, the web owner might decide to load alternative content based on the value of a certain cookie (i.e.
nabAlternative
).I looked at your source code (more specifically, your third-party integrations) and noticed you provide (I think) two filters for that (
litespeed_vary_cookies
andlitespeed_vary_curr_cookies
). If I add the following snippet in our plugin:function add_nab_alternative_as_dynamic_cookie( $cookies ) { if ( ! is_cookie_testing_enabled() ) { return $cookies; }//end if $cookies[] = 'nabAlternative'; return $cookies; }//end add_nab_alternative_as_dynamic_cookie() add_filter( 'litespeed_vary_curr_cookies', __NAMESPACE__ . '\add_nab_alternative_as_dynamic_cookie' ); add_filter( 'litespeed_vary_cookies', __NAMESPACE__ . '\add_nab_alternative_as_dynamic_cookie' );
would things work as expected?
I also have a few more questions that I’d like you to address:
- Should we add the aforementioned code in our plugin to make Nelio compatible with LiteSpeed? Or would it be better if you make yours compatible with ours?
- If a visitor lands on a tested page and they don’t have a
nabAlternative
cookie yet, how does your plugin behave? Is the cache bypassed and WordPress runs on its own? - I’ve seen other cache plugins create a special config file which we need to regenerate when toggling on/off the setting to enable cookie-testing in Nelio. Is that also necessary in LiteSpeed?
Thanks!
- The topic ‘Caching Filters for Plugin Developers’ is closed to new replies.