How To Remove Cookie In WordPress Plugin Wp Super Cache Http Response Header Vary

WP Super Cache is a very popular WordPress plugin. It can generate html version of all your WordPress articles. Then when client browser request your article, it will return the html version instead of executing dynamic web page. This can improve page response speed and make your website more efficient.

But when you look at your web page http response header generated by WP Super cache, especially the Vary header’s value, you will find the Vary header value include string ‘Cookie’ like below picture ( Vary: Accept-Encoding, Cookie ).

connect to my website server directly

This will make intermediary proxy server’s cache or your web browser’s cache inefficient. Because the cache will save cached web page by cookie value, so every time a request to the same web page from different cookie user, the proxy server will get the web page from the original web server, not from the cached web page, this make the cache not working at all. You can read article How To Set Http Header Vary Value Correct To Make Cache Work Effective to learn more.

1. How To Find The Php Source File That Add Vary Header.

  1. Download your WordPress webstie source code into your local computer.
  2. Install a file editor, like sublimetext
  3. Start sublimetext, click File —> Open Folder menu item, and select your WordPress source code folder.
    sublimetext file open folder menu item
  4. Click Find —> Find in Files menu item to open find text panel.
    sublimetext find find in files menu item
  5. Now you will find a popup panel at sublimetext window bottom. Select the first .* (Regular expression), input text Vary: Accept-Encoding, Cookie in the Find text box, click Find button.
    sublimetext find in files popup panel
  6. Now you will see the below source code in above Find Results window.
      168  				}
      169  			} else {
      170: 				header( "Vary: Accept-Encoding, Cookie" );
      171  			}
      172  			if ( defined( 'WPSC_CACHE_CONTROL_HEADER' ) ) {
     1195  		}
     1196  	} else {
     1197: 		header( 'Vary: Accept-Encoding, Cookie' );
     1198  	}
  7. Above code shows the php file path is \wp-content\plugins\wp-super-cache\wp-cache-phase2.php. That means the Vary header value is added by WordPress plugin WP Super Cache.
  8. Click the file name in Find Results window will go to file wp-cache-phase2.php source code, and you can find below php code. You can find the http response header ‘Vary: Accept-Encoding, Cookie’ is hard coded. This is because wp super cache want to enable cache for logined users with cookie value.

2. How To Reomve Cookie From WP Super Cache Vary Header Value.

  1. But you can override it by define your own Vary header value in constant variable WPSC_VARY_HEADER in wp-config.php file. The wp-config.php file should be located in the WordPress root folder.
    if ( defined( 'WPSC_VARY_HEADER' ) ) {
        if ( WPSC_VARY_HEADER != '' ) {
        header( 'Vary: ' . WPSC_VARY_HEADER );
    } else {
        header( 'Vary: Accept-Encoding, Cookie' );
  2. Edit the wp-config.php file at the WordPress website root folder, add below code.
    define('WPSC_VARY_HEADER', 'Accept-Encoding');
  3. Browse the web page again, the Vary header value will not contain Cookie.

3. Why Other Method Do Not Take Effect.

If you have read article How To Modify Http Response Header In WordPress, you may wonder why that article do not take effect on WP Super Cache plugin. This is because WP Super Cache modify the http Vary header when it generate the static html web page. This action will be implemented after all those methods. So for WordPress plugin like WP Super Cache, you must edit it’s source code.


  1. How To Modify Http Response Header In WordPress
  2. How To Set Http Header Vary Value Correct To Make Cache Work Effective
  3. How To View HTTP Headers, Cookies In Google Chrome, Firefox, Internet Explorer
  4. How To Connect Directly To Your Origin Web Server Bypass Intermediary Proxies To View Original Http Headers
0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x