We use cookies to make Serpstat better. By clicking "Accept cookies", you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Learn more

Report a bug

Cancel
2766
How-to 4 min read

How to use the Vary HTTP header and why you need it

The Vary header is used to display the requested content of the page when it is cached. The most relevant use of this header in the presence of several versions of dynamic or static pages under the same URL.

What is the HTTP Vary header used for?

It's not always possible to create a unique address for each page. For example, if there is a mobile and regular version or the page is multilingual. In order to open the requested content to the user, the Vary HTTP header is set. Accordingly, if you do not use it, then the user-agent may choose the wrong option from those stored in the cache.
User-agent is an application in HTTP text string format that sends the server information about the browser, OS type, language version, etc.
It is very important to set this header correctly, otherwise, you will make it worse than before. The caching process is designed to reduce time and resources by itself when transferring data from the browser to the original server through several clipboards. Incorrectly configured HTTP headers can break this sequence.

Often, HTTP Vary is used to detect compressed and uncompressed data when dynamically displaying pages. In this case, accept-encoding is used. If the user's browser is not able to process Gzip-compressed content, information is sent in an uncompressed form. This is necessary to improve the appearance of the pages and the content contained on them.

User-agent helps not only to distinguish content versions but also to quickly recognize information by search bots. So Vary header can be partially considered an SEO optimization tool, but you should not specifically configure it for bot recognition.

The most common problems with Vary HTTP

Google Developers identifies several popular problems associated with the definition of user-agent:
1
Obsolete user-agents may not be detected correctly. To avoid this, the list of agents must be regularly updated while deleting old versions.
2
Complex recognition of the type of browser in the user-agent.
3
Confusion with page versions due to incorrect search words. For example, when defining a mobile version, it is better to use the word mobile than android.

Conclusion

The Vary header helps you to identify the correct version of a page among all available under the same URL. To configure, you must specify the correct value for the header and in time to refresh the list of available agents.

This article is a part of Serpstat's Checklist tool
Checklist at Serpstat" title = "How to use the Vary HTTP header​ and why you need it 16261788326062" />
Checklist is a ready-to-do list that helps to keep reporting of the work progress on a specific project. The tool contains templates with an extensive list of project development parameters where you can also add your own items and plans.
Try Checklist now

Learn how to get the most out of Serpstat

Want to get a personal demo, trial period or bunch of successful use cases?

Send a request and our expert will contact you ;)

Rate the article on a five-point scale

The article has already been rated by 0 people on average out of 5
Found an error? Select it and press Ctrl + Enter to tell us