AtulHost
  • Business
    • Career and Education
    • Finance and Investments
    • Marketing Strategies
  • Productivity
  • Technology
    • Consumer Electronics
    • Solar Energy
  • Tutorials

How to fix “Specify a Vary: Accept-Encoding Header” warning?

By AtulHost in Tutorials ⋅ November 28th, 2020
Facebook Tweet LinkedIn

While optimizing your website for website performance using tools (ex. GTmetrix), you’ll run into a “specify a vary: accept-encoding header” warning.

What exactly does this mean? How can we fix this? In this tutorial, we’ll learn what’s the error and how we are going to resolve the issue.

What is this warning?

Accept-encoding header is an HTTP header that must be included on every origin server response in order to inform the browsers if the client can handle the compressed (zipped) version of the website or not.

The warning could appear when you don’t use the “Vary: Accept-Encoding” in your header on a server or content delivery network (CDN) settings. If you do not use this setting properly, this will cause many issues like sending the compressed version of your website to the old browser. Though it is not a major issue because the majority of users are only using a modern browser, only a few of us are using old ones.

But not using this setting can actually affect your website’s performance in front of clients, especially when your target audience is every single user in the world.

Where to find this warning?

The warning is not visible on modern browser, but we can find the issue either in old browser or with a CDN when implemented with website for performance.

But we can find this warning by conducting website performance analysis tools like GTmetrix or Pingdom. Once you enter your website’s URL on their tool, you’ll see all sorts or performance issues and warnings highlighted by the tool.

But do not worry, we’ll see how to easily fix this warning.

Fixing “Specify a Vary: Accept-Encoding Header” warning from the web server.

To fix this waning, we need to tell our web server and it’s configuration to add that “vary: accept-encoding” header for the compressed files or file extensions.

Users who use the Apache webserver.

Making changes in Apache is more simple, all you need to find .htaccess file located in the root directory of the website. Using file manager, or FTP client you can modify the file and add the below configuration to fix the warning.

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

Before modifying, I’ll recommend making a backup of existing .htaccess file.

Users who use the Nginx webserver.

To fix the same warning in Nginx, you’ll need to modify the configuration file in your virtual or dedicated server via SSH. The configuration file that you need to modify is located at /etc/nginx/nginx.conf in rare cases, the location may differ.

Once you’ve located the configuration file, just add the below line in the gzip section or after gzip on; which can be found inside the HTTP block.

gzip_vary on;

Once the directive is added, save the file, and reload the server. You can restart too but that’s not recommended on a live site with many users visiting your website.

systemctl reload nginx

If you want to restart nginx just replace above reload word with restart.

Now, it’s testing time.

Wait, before testing, clear the cache if you are using any caching plugin.

Once you recheck the website in the same tools, you’ll see the warnings are gone and you can focus on other issues and warnings.

Content is tagged with apache, HTTP Header, nginx, PageSpeed, web server, website, website performance.
Facebook Tweet LinkedIn

You’ll also like:

  • Why Website Localization is Important for Global Marketing?
  • How a Web Hosting Choice Can Affect SEO?
  • Web Hosting and Cybersecurity: Is Your Web Host Applying Necessary Safety Precautions?
  • 5 ways to analyze your website traffic and increase conversions
  • Query Strings Remover: WordPress Plugin
  • Some Powerful Ways to Improve Your Website’s Ranking in Google
  • Increase Website’s Revenue with Affiliate Marketing
  • Shared vs. Virtual Private vs. Dedicated Servers
  • How to enable hotlink protection in Nginx?
  • How to install phpMyAdmin on Debian 10?

Published by AtulHost

Atul is a creative blogger who loves to do experiments with the latest business initiatives and tech trends like automation, artificial intelligence, cloud and edge computing, data science, hardware as well as networking, and the internet of things.

Make a comment Cancel reply

Required fields are asterisked and your email address will not be shared.

Subscribe

Recent Posts

  • Transitioning your startup out of the beginning stages
  • HR trends for 2021
  • How to pick the right financing company for your customers
  • How to reduce initial server response time?
  • What every ecommerce business needs to know when it comes to product images
  • What is shared hosting?
Taking care of communication within your small business
Best laptop brands
Cool business ideas

We serve cookies on this site to offer the excellent user service.

  • About
  • Contact
  • Privacy Policy
  • Terms and Conditions
  • Write for Us
This website and its content are copyrighted © 2014-2021 by atulhost.com and individual contributors.