Title: Supress Cache
Last modified: January 24, 2023

---

# Supress Cache

 *  Resolved [Maya](https://wordpress.org/support/users/tdgu/)
 * (@tdgu)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/supress-cache/)
 * Hi,
   Is there a way to ignore the cached page data ( to not serve it ) if a specific
   cookie is not set? I presume that has to be done through the .htaccess file.So
   when a user loads the website, the WordPress/plugins php code gets always executed
   rather than a cached page loaded from the static file, the W3 cache previously
   loaded. That until the specific cookie exists, then the cached will be served.
 * Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/supress-cache/#post-16403889)
 * Hello [@tdgu](https://wordpress.org/support/users/tdgu/)
 * Thank you for reaching out.
   I just want to confirm that I understood your request.
   What you want is to be able to serve cached pages only if a specific cookie is
   set and not to serve cached pages at all unless that cookie is set.Please let
   me know if I understood this correctly.
 * Thanks!
 *  Thread Starter [Maya](https://wordpress.org/support/users/tdgu/)
 * (@tdgu)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/supress-cache/#post-16403932)
 * Hi,
   Yes, this is correct. I need the cached pages to be served **Only** if a 
   specific cookie exists on the user side (browser).Thanks
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/supress-cache/#post-16404461)
 * Hello [@tdgu](https://wordpress.org/support/users/tdgu/)
 * I am not quite sure this is possible as usually, the users want to prevent serving
   of the cached pages when specific cookie is set.
   In Performance>Cache Groups,
   you can enable/add a group of of Cookies by specifying names in the Cookies field.
   Assign a set of Cookies to ensure that a unique cache is created for each Cookie
   group.So adding a specific cookie for some pages, and then excluding that cookie
   from the cache may be the way to go, and with managing the cookie group allowing
   the unique cache to be created for the set cookie.I need to check and test this
   more. Thank you for you patience and I’ll get back to you as soon as I have more
   information.
 * Thanks!
 *  Thread Starter [Maya](https://wordpress.org/support/users/tdgu/)
 * (@tdgu)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/supress-cache/#post-16405579)
 * Hi,
   What do you think of an additional line within the rewrites:
 *     ```wp-block-code
       RewriteCond %{REQUEST_METHOD} !=POST
       RewriteCond %{ENV:W3TC_QUERY_STRING} =""
       RewriteCond %{HTTP_COOKIE} (serve_if_this_cookie) [NC]
       RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
       RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache) [NC]
       RewriteCond "%{DOCUMENT_ROOT} ...../wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SLASH}%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
       RewriteRule .* "....../wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SLASH}%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
       ```
   
 * Notice the cookie check **RewriteCond %{HTTP_COOKIE} (serve_if_this_cookie’) [
   NC] **There is another similar block where that would go. 
   Will that work? If
   yes, is there a filter which I can use to insert that line?Or maybe there is 
   more, of which I’m not aware?Thanks
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/supress-cache/#post-16459837)
 * Hey [@tdgu](https://wordpress.org/support/users/tdgu/)
 * Sorry for the late reply.
   I’ve checked this and there is no way to do this via
   the W3 Total Cache settings.
 * This being said, your solution may work.  The `.htaccess` file can include a 
   rule above ours to override the cache rewrite behavior.
   Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Supress Cache’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/supress-cache/#post-16459837)
 * Status: resolved