Cookies caching exception | WordPress.org

[ad_1]

Hi,

Cachify does not actually cache cookies. I assume you want to exclude cache generation/display when a user request contains a certain cookie?

You can achieve this using the cachify_skip_cache hook, e.g.

add_filter(
  'cachify_skip_cache',
  function( $skip ) {
    return $skip || isset( $_COOKIE['cookie_name'] );
  }
);

If you use HDD caching with direct webserver configuration, you need to extend this as well.

nginx
Extend

if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
  return 405;
}

with cookie name as required:

if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_|cookie_name ) {
  return 405;
}

Apache (htaccess)

Extend

RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_

to

RewriteCond %{HTTP_COOKIE} !((wp-postpass|wordpress_logged_in|comment_author)_|cookie_name)

Cheers,
Stefan

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer