Bypass cache if a cookie is present.
-
Hello good morning.
First of all thank ?? you for the wonderful plugin you have made, it’s great??.
I have a problem with caches, me and half the world ?? .
I use SiteGround, Kinsta and others, the problem is the same on all hosting.
I accept cookies but the blocked content is not seen because it is being served with cache, normal.
If I disable the cache, the plugin works perfect.
I want to know how to bypass the cache if the “cookies_and_content_security_policy” cookie of the plugin is present.
I know Siteground bypasses the cache if these cookies are present:
wordpress_logged_in_, yith_wcwl_products, wp-postpass_, edd_items_in_cart=1, it_exchange_session_, wp_woocommerce_session, woocommerce_cart_hash, woocommerce_items_in_cart=1, Drupal.visitor.name, drupalSGCacheBypass=1, jSGCacheBypass=1, wpSGCacheBypass=1.
I have in my functions.php
add_action('init', function() { if (isset($_COOKIE['cookies_and_content_security_policy'])) { if ( class_exists( 'SiteGround_Optimizer\Supercacher\Supercacher' ) ) { SiteGround_Optimizer\Supercacher::purge_cache(); } } });
With this code everything works but in order to see the blocked content the user has to click on accept cookies and refresh the page ??.
I have found in Github a code that they use to deactivate the caches of many hosting: https://github.com/WPHercules/wph-server-cache-helper/blob/master/wph-server-cache-helper.php
I don’t know if you can do something to implement that code in your plugin to disable caches when accepting cookies.
Or if you can do something to make the page reload when you click the accept cookies button, I know it’s not perfect but it’s better than nothing.
Can you help me?
Thank you very much ??.`
- The topic ‘Bypass cache if a cookie is present.’ is closed to new replies.