September 25, 2019
3 min Read
September 25, 2019
3 min Read
It’s possible that you will run into “specify a vary: accept-encoding header” warning when checking your website performance. But what exactly does this mean? How can you fix this?
In this article, you will learn what the error is. We are also going to tell you how to resolve the issue.
Before we show you how to fix this problem, let’s learn what a specify a vary: accept-encoding header warning is and how to tell if your site is suffering from it.
Accept-encoding header is an HTTP header which must be included on every origin server response. Its main job is to inform the browsers if the client can handle the compressed version of the website.
The warning can appear when you don’t use the Vary: Accept-Encoding in your header on a server or CDN. This will cause either of them to deliver the uncompressed version of your website to modern browsers.
While not on purpose, this can actually affect your site’s performance in front of the clients, though it’s not major.
After entering your website’s URL, those performance analyzers will highlight if there is such an error. But worry not, we’ll tell you how to easily fix the problem in a minute.
This tutorial will require you to insert several lines of code, thus a bit technical knowledge would be great. If you’re not sure, you might need to call a professional to help you.
That being said, we’re going to show you how to fix Specify a Vary: Accept-Encoding Header warning on the two most popular web servers — Nginx and Apache.
To fix this issue on Nginx, you need to navigate to the primary configuration in your VPS via SSH. The location is at /etc/nginx/nginx.conf.
If you’re not sure how to access your VPS, check out our PuTTY SSH tutorial!
Once you find the file, you need to add or modify the line gzip_vary:
For this, feel free to use your preferred text editor.
Then, save it and restart the apache service. Your error should be fixed now.
While in Nginx server you have to know how to access your VPS using ssh command, resolving the warning on Apache is a bit more simple.
You only need an FTP client like FileZilla to navigate to your websites’ files. Then, you should find and edit your .htaccess file.
However, we should warn you that, you have to be very careful when editing any files through FTP. It is highly recommended for you to perform file backup in case anything goes wrong.
Once you’re ready with the .htaccess, you will have to add or modify this snippet to look exactly like this:
<IfModule mod_headers.c> <FilesMatch ".(js|css|xml|gz|html)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule>
You want your site performance to be excellent all the time, right? Therefore, it is important to know how to fix issues that might hamper it, including the specify a vary: accept-encoding header problem.
The process of fixing it is relatively easy when you follow our instruction correctly, either on Apache or Nginx server. The thing is, you will need to be careful in doing so because you might damage your site or server.
We hope this tutorial can help you fix the problem and achieve the best version of your website.