How to Fix “Specify a Vary: Accept-Encoding Header” Warning ?

The affects of Web Hosts on Your Business Website

Here're ways your choice of web hosting service provider impacts the performance of your business:


check

Website loading speed

check

Uptime and availability

check

Customer support

check

Security

check

Server location

How to Fix “Specify a Vary: Accept-Encoding Header” Warning

How to Fix “Specify a Vary: Accept-Encoding Header” Warning

Fix “Specify a Vary: Accept-Encoding Header” Warning

On your WordPress site, are you getting the “Specify a Vary: Accept-Encoding Header” warning from Pingdom, GTmetrix, or Google PageSpeed Insights? This is an HTTP header that should be included in every origin server response since it tells the browser whether or not the client can process compressed information.

Let’s imagine you have an outdated browser that doesn’t support gzip compression and a modern browser that does. If you don’t use the Vary: Accept-Encoding header, your web server or CDN may cache the uncompressed version and provide it to current browsers by accident, causing your WordPress site to perform poorly. You may verify that your web server and/or CDN send the correct version by using the Vary: Accept-Encoding header.

The warning may appear in one of two ways, depending on the tool or software that generated it:

“Vary: Accept-Encoding Header” is required.
A “vary: accept-encoding” header should be included to the following publicly cacheable, compressible resources.
In Pingdom, set a Vary: Accept-Encoding header warning.
To fix the “Specify a Vary: Accept-Encoding Header” warning, follow the steps below.

Fix “Specify a Vary: Accept-Encoding Header” Warning

The first thing to remember about this warning is that it can only be fixed for requests that originate from your server. If you’re seeing this on 3rd-party requests, there’s nothing you can do because you don’t have control over their web servers. However, please feel free to forward this material to them. Because the Vary: Accept-Encoding header is inserted by default on all Gregghosting servers (as seen below), if you are a Gregghosting customer, you will never receive this warning and will not have to worry.

accept-encoding header gregghosting
On g=Gregghosting servers, the Accept-Encoding header varies.
Both your WordPress assets and your original server request are affected by the header. If you’re utilizing a CDN, many of them will apply the Vary: Accept-Encoding by default to your content. This is used by KeyCDN, Cloudflare, and CloudFront. This is also included in many WordPress caching plugins.

You’ll need to add some code to your server if you still need to fix this.

“Specify a Vary: Accept-Encoding Header” has been fixed. Apache issues a warning.
Add the following code to your.htaccess file through FTP to solve issues in Apache. This file is located in the root directory of your server. If your permissions are configured appropriately, you may also use the Yoast SEO plugin to alter your.htaccess file.

Important! If you don’t do it right, editing your.htaccess file can ruin your site. If you are unsure about doing so, please contact your web host first.
IfModule mod headers.c mod headers.c mod headers.c mod headers.c mod headers.
‘FilesMatch’ is a program that matches files “..
(js|css|xml|gz|html)$”>
/FilesMatch> /IfModule> Header add Vary: Accept-Encoding
In NGINX, fix “Specify a Vary: Accept-Encoding Header.”
Add the following code to your NGINX config file to remedy this. The /etc/nginx/ directory contains all NGINX configuration files. /etc/nginx/nginx.conf is the main configuration file.

Accept-gzip vary on Using the Vary: Accept-gzip vary on Using the Vary: Accept-gzip vary on

Encoding headers can really help your WordPress site load faster by ensuring that you’re using gzip compression. And if all goes well, and you don’t have any 3rd-party requests that aren’t using the header appropriately, you should see an increase in your score using website performance test tools like Pingdom (as seen below).

Accept encoding header with a score of 100
Fixed Set a Variable: Warning in the Accept-Encoding header
Save time, money, and improve site performance by using:

Expert WordPress hosting assistance is available 24 hours a day, 7 days a week.
Integration with Cloudflare Enterprise.
With 29 data centers across the world, we can reach a global audience.
With our built-in Application Performance Monitoring, you can improve your performance.
All of this and more is included in a single plan that includes no long-term obligations, aided migrations, and a 30-day money-back guarantee. Check out our plans or speak with a sales representative to find the ideal plan for you.