Are you seeing the “Specify a Vary: Accept-Encoding Header” warning in Pingdom, GTmetrix, or Google PageSpeed Insights on your WordPress site? This is an HTTP header and should be included on every origin server response, as it tells the browser whether or not the client can handle compressed versions of the content.
For example, let’s say you have an old browser without gzip compression and a modern browser with it. If you don’t utilize the Vary: Accept-Encoding header your web server or CDN could cache the uncompressed version and deliver that to the modern browser by mistake, which in turn hurts the performance of your WordPress site. By using the Vary: Accept-Encoding header you can ensure that your web server and or CDN delivers the appropriate version.
Depending upon the tool or software reporting it, the warning might appear in a couple different ways:
- “Specify a Vary: Accept-Encoding Header”
- The following publicly cacheable, compressible resources should have a “vary: accept-encoding” header
Follow the steps below on how to fix the “Specify a Vary: Accept-Encoding Header” warning.
Fix “Specify a Vary: Accept-Encoding Header” Warning
The first thing that is important to note about this warning is that you can only fix this for requests that are on your server. If you have 3rd party requests you are seeing this on, there is nothing you can do as you don’t have control over their web servers. Although feel free to share this article with them. The Vary: Accept-Encoding header is added by default on all Kinsta servers (as seen below), so if you are a Kinsta customer you won’t see ever see this warning and don’t have to worry about.
The header applies both to your WordPress assets and your original server request. For your assets, if you are using a CDN, many already apply the Vary: Accept-Encoding by default. KeyCDN, Cloudflare, and CloudFront all utilize this. A lot of WordPress caching plugins also add this.
If you are still needing to fix this, you will need to add some code to your server.
Fix “Specify a Vary: Accept-Encoding Header” Warning in Apache
To fix this in Apache, add the following code to your .htaccess file via FTP. This file can be found on the root of your server. You can also edit your .htaccess file with the Yoast SEO plugin if your permissions are set correctly.
<IfModule mod_headers.c> <FilesMatch ".(js|css|xml|gz|html)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule>
Fix “Specify a Vary: Accept-Encoding Header” in NGINX
To fix this in NGINX, add the following code to your config file. All NGINX configuration files are located in the
/etc/nginx/ directory. The primary configuration file is
Using the Vary: Accept-Encoding header can in fact help speed up your WordPress site as it will ensure you are using gzip compression. And if all goes well, and you don’t have any 3rd party requests that aren’t correctly using the header, you should see an improvement on your score with website speed test tools such as Pingdom (as seen below).
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans