Title: Header Vary Accept Encoding cache control
Last modified: July 17, 2017

---

# Header Vary Accept Encoding cache control

 *  Resolved [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/)
 * Trying to get the header working and have not been able to either in includes
   file or htaccess for Apache. Cache Control for pages is also not working. security
   headers are working.
 *     ```
       # Cache control header
       <FilesMatch "\.(html|gz|php|htm)$"> 
       Header set Cache-Control "max-age=86400, no-cache"
       </FilesMatch>
       ```
   
 *     ```
       <IfModule mod_headers.c>
         <FilesMatch "\.(js|css|xml|gz)$">
           Header append Vary: Accept-Encoding
         </FilesMatch>
       </IfModule>
       ```
   
 * Also tried
 *     ```
       <IfModule mod_headers.c>
           Header set Vary "Accept-Encoding"
       </IfModule>
       ```
   
 * Cache control is working for images, css etc because of cdn respecting my headers.
   Not sure why it’s not working on pages even though it returns a content encoding
   and last modified. Any hints?

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

 *  [codyarsenault](https://wordpress.org/support/users/codyarsenault/)
 * (@codyarsenault)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9325618)
 * Is it only not working when Cache Enabler is enabled?
 *  Thread Starter [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9326286)
 * So I checked and WordPress was only sending a header if I was logged in so I 
   added the Cache Control plugin and tested again:
 * Cache Enabler enabled:
 *     ```
       Status: HTTP/1.1 200 OK
       Date:	Mon, 17 Jul 2017 15:29:30 GMT	
       Server:	Apache	
       x-cache-handler:	wp	
       Content-Encoding:	gzip	
       Strict-Transport-Security:	max-age=31536000; includeSubDomains; preload	
       Access-Control-Allow-Origin:	*	
       X-Content-Type-Options:	nosniff	
       X-Xss-Protection:	1; mode=block	
       X-Frame-Options:	SAMEORIGIN	
       Content-Security-Policy:	default-src https:; script-src https: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:	
       Referrer-Policy:	no-referrer-when-downgrade	
       Upgrade:	h2	
       Connection:	Upgrade, close	
       Last-Modified:	Mon, 17 Jul 2017 15:28:13 GMT	
       Content-Length:	24693	
       Content-Type:	text/html; charset=UTF-8
       ```
   
 * Disabled:
 *     ```
       Status: HTTP/1.1 200 OK
       Date:	Mon, 17 Jul 2017 15:31:01 GMT	
       Server:	Apache	
       Cache-Control:	max-age=86400, s-maxage=2700	
       Link:	<https://grantdb.ca/>; rel=shortlink	
       Strict-Transport-Security:	max-age=31536000; includeSubDomains; preload	
       Access-Control-Allow-Origin:	*	
       X-Content-Type-Options:	nosniff	
       X-Xss-Protection:	1; mode=block	
       X-Frame-Options:	SAMEORIGIN	
       Content-Security-Policy:	default-src https:; script-src https: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:	
       Referrer-Policy:	no-referrer-when-downgrade	
       Upgrade:	h2	
       Connection:	Upgrade, close	
       Content-Length:	150180	
       Content-Type:	text/html; charset=UTF-8
       ```
   
 * Either way the accept header is not being sent.
    Note: I also do not have Apache
   doing any compression as I have this plugin and the cdn take care of that.
 * Thanks
 *  [Dan](https://wordpress.org/support/users/geekysoft/)
 * (@geekysoft)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9327581)
 * Psst: `Header always set …`
    -  This reply was modified 8 years, 10 months ago by [Dan](https://wordpress.org/support/users/geekysoft/).
 *  Thread Starter [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9327659)
 * Tried this:
 *     ```
       # Vary accept encoding
       <IfModule mod_headers.c>
           Header always set Vary "Accept-Encoding"
       </IfModule>
       ```
   
 * No worky,
    Thanks!
 *  Thread Starter [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9342886)
 * Ok so for the Vary I figured out that, on my server, I was putting the directive
   under a <Directory> block and when I have it in my includes file by itself it
   works!
 * `Header append Vary Accept-Encoding`
 * Still working on the cache headers but figured out it is something to do with
   having a static front page set. On single post pages the cache control is working
   correctly.
 *  Thread Starter [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9343342)
 * From what I can understand in the sea of vague information is that for client
   browsers the cache control is used for static resources like css, js and images
   etc Basically the first page load is a complete load of the page and all resources.
   On reload and clicks of other pages of the website the resources use the cache
   control/etag etc to load from cache.
 * Long story short, last-modified is great for my pages and cache control for the
   resources.
 * My head hurts…
 * Cheers!
 *  [Dan](https://wordpress.org/support/users/geekysoft/)
 * (@geekysoft)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9343352)
 * Last-Modified is used for cache revalidation, whilst the Cache-Control header
   instructs clients about the expected freshness of a resource. E.g. a resource
   with `Cache-Control: must-revalidate` plus `Last-Modified: $date` instructs clients
   to request the resource anew every time with a `If-Modified-Since: $date` header–
   and the expectation that the server will always respond `304 Not Modified`. A
   response with `Cache-Control: max-age=7200` instructs the client to reuse a cached
   copy of the resource and don’t ask the server for a new version for 2 hours (
   60*60*2 seconds). Though, a `Age: 200` response header would instruct the client
   to knock off 200 seconds off the `max-age` duration. Hm, I may be making things
   worse here as I try to explain them.
 *  Thread Starter [grantdb](https://wordpress.org/support/users/sixer/)
 * (@sixer)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9344472)
 * Exactly, thanks for explaining better than me 😉
 * This is how I have it working for all my assets but have not been able to do 
   this with pages.
 * Cheers!

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

The topic ‘Header Vary Accept Encoding cache control’ is closed to new replies.

 * ![](https://ps.w.org/cache-enabler/assets/icon.svg?rev=2442383)
 * [Cache Enabler](https://wordpress.org/plugins/cache-enabler/)
 * [Support Threads](https://wordpress.org/support/plugin/cache-enabler/)
 * [Active Topics](https://wordpress.org/support/plugin/cache-enabler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cache-enabler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cache-enabler/reviews/)

## Tags

 * [apache](https://wordpress.org/support/topic-tag/apache/)
 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [header](https://wordpress.org/support/topic-tag/header/)

 * 8 replies
 * 3 participants
 * Last reply from: [grantdb](https://wordpress.org/support/users/sixer/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/header-vary-accept-encoding-cache-control/#post-9344472)
 * Status: resolved