Enable Specify A Vary: Accept-Encoding Header To Speed Up WordPress
In this article we will be learning How You can fix Specify A Vary: Accept-Encoding Header warning in gtmetrix and Pingdom tool on Your WordPress website so that you can increase your website performance grade. We will fix this warning for htacess, Nginx, PHP WordPress, and its Servers. You will face this error or warning in like Pingdom, GTmetrix. or webpagetest
What is Vary Header?
Vary Header is a very important HTTP header of our website. It ensures that the right content (compressed or uncompressed) should be delivered to a particular browser when requested.
Concept elaboration in detail
Nowadays we have two kinds of browsers. Modern Browser accepts gzip compression and the second one is the old browser which doesn’t understand gzip compression. Let’s say the first visitor is using a modern browser and you haven’t enabled Vary: Accept-Encoding Header then your server will deliver the cached version of gzip-compressed content. And now let say the second visitor is using an old browser and your cache server have to gzip compressed content and it will deliver to the second visitor. Since the old browser doesn’t understand gzip compression so the delivered content will be unreadable for your visitor. This case becomes more complicated when the proxy server comes in between the client browser and cached server. So in this case vary header will only deliver the right content.
How to Fix “Specify a Vary: Accept-Encoding Header” warning using htaccess (Apache server)
You need to paste the below code in the .htacess file
Header append Vary: Accept-Encoding
How to Fix “Specify a Vary: Accept-Encoding Header” Warning NGINX server
You need to add it to your NGINX server config file Path followed will /etc/nginx/nginx.conf
Vary: Accept-Encoding Header IIS
You need to edit the web.config file
<?xml version="1.0" encoding="UTF-8"?>
<add name="Vary" value="Accept-Encoding"></add>
Best WordPress plugins to fix Specify a Vary: Accept-Encoding Header are as follows
You need to install this plugin and activate it. Once you are done the above-mentioned code will get added to your .htacess file.Download