Vary header not set to enable Accept-Encoding

Rule from network under performance category

What is a trooper!

we have submitted your edit to the community for review! We'll review and make it live on the site in the next few hours, the internet thanks you :).

Browse another section of the knowledge base



Suggest an edit

Cancel

This rule has no content... yet.

Add content to this rule

Or just browse to view rules that have content



 

The Vary header lets browser clients define how the server identifies each request. This allows the server to control how caching is handled on all it's clients.

The "Accept-Encoding" is a quick way to tell clients and caching servers how to handle requests where GZIP is on and off, treating them as the same or unique.

When "Accept-Encoding" is configured as one of the options in Vary the GZIP and NON-GZIP request would be treated as unique, allowing browsers that do not support GZIP to still access the site.

How do I fix this ?

To fix simply define the header, with at a minimum the "Accept-Encoding" option.

Apache

If using Apache (and most probably a shared environment) create/edit the .htaccess file in the root of the site with the following content:

<IfModule mod_headers.c>
  <FilesMatch ".(js|css|xml|gz|html)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>

NGINX

To define the header in your location or server block use the following:

gzip_vary on

IIS

Define the setting in web.config:

<system.webServer>
  <httpProtocol>
    <customHeaders>
    <remove name="Vary"></remove>
    <add name="Vary" value="Accept-Encoding"></add>
    </customHeaders>
  </httpProtocol>
</system.webServer>

Resources

Browse another section of the knowledge base



Signup icon
Ready to see how well your site scores?

Passmarked works best when you have an account. It allows you to keep a dashboard with saved data of the sites you have run through the system, we’ll alert you about important updates and you get access to the Passmarked Slack forum.

Sign up to get started