The ‘Specify a vary: accept-encoding header’ warning is commonly found on WordPress sites. It means that there is a chance your web server could cache the uncompressed version of your sites to users of older browsers. If this occurs, then the performance of your site will suffer.
Time needed: 30 minutes.
In this article, you will discover how to fix this error code.
- Ensure your site has a good CDN.
Many of the CDN plugins available for WordPress use vary:accept-encoding, Cloudflare is one example.
- Contact your web host.
If the previous step didn’t solve your warning, then you should contact your web host. Getting the web host to look into your code saves you from doing it yourself and potentially breaking your site. The code that needs changing is included below.
How to Fix the Warning With New Code
If your web server is NGINX, then you need to navigate to the primary configuration via SSH in your VPS. The location will be /etc/nginx/nginx.conf. Once you have found the file, modify or add the line gzip_vary to show ‘gzip-vary on’. You can use any text editor to change this line of code, then save it and restart the webserver service. The warning should now be fixed.
If your web server is Apache, then you have a bit more luck than those using NGINX because the issue is easier to solve on Apache servers. Use any trustable FTP client such as FileZilla to find and then begin editing your .htaccess file. You then need to find the <IfModule mod_headers.c> line and edit it to look like this:
Header append Vary: Accept-Encoding
Then save your file and restart the webserver service to clear the warning message.
Fixing the Error in Short
To conclude, the Specify a vary: accept-encoding header is a warning that occurs on HTML websites. It indicates an issue with providing users with the correct version of the web page they wish to view. If the wrong compressed file is sent to the user, it could result in longer load times and more unsatisfactory overall performance. By using a functioning vary: accept-encoding header, your site increases its performance, and the loading times for users are shortened. Keeping site visitors happy with speedy loading times and good site performance is at the front of every website owner’s mind. Hopefully, you have enjoyed reading this article and have solved your warning of ‘specify a vary: accept-encoding header’, and your site is now running more efficiently.
Thank you for reading. If you liked this article, be sure to check out our other articles. You may also like our article about how to edit HTML in WordPress.