Vary Response Header

Vary Response Headers are used for displaying website content via CSS or HTML appropriately for the User Agent who is accessing the site. For the user, the use of the http header has the advantage that the accessed content is as optimized as possible for the device. The use of Vary Response can therefore increase the usability of a page.

Background

As soon as a browser tries to access a website, the http-Header of the respective page provides an answer which helps the client render the page usable to readers. This plays a role particularly when the user accesses the internet not only via Desktop PC (as would have been the case a few years ago), but also surfs the web on tables or smartphones. If the web server recognizes the user, but cannot provide the suitable content, this often leads to websites not being able to work properly, or being unable to load. The same applies for web crawlers. Via the Vary-http-header, web crawlers get an indication that the website version is ready to be displayed on mobile devices and desktops.

Functions

A Vary Response Header fulfils, according to its design, the following functions:

  • It gives Cache-Servers of providers the indication that, whilst requesting the Cache, the User-Agent also has to be considered.
  • It helps Web Crawlers quickly identify and index mobile optimized content
  • It shows that a compression of the page is available

Examples

As soon as a client “requests” a server, he gets an answer over the http-header.

  • The user agent should be considered when displaying the content
Vary: User-Agent


  • A complete answer can look like this
GET /page-1 HTTP/1.1
Host: www.beispielseite.de

HTTP/1.1 200 OK
Content-Type: text/html
Vary: User-Agent
Content-Length: 5710


  • The client should then know what compression the website uses.
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Encoding: gzip

Uses for Usability

With the Vary Response Header, webmasters can ensure that clients can read their websites correctly. On the one hand, users can access the correct version for their device. On the other hand, search engines have the possibility to work out whether mobile optimized content is available. In this way, the server shows that no cloaking is intended. They can consider this with the indexing, and give users in the SERPs the appropriate indication. If users use a search engine with a smartphone or a desktop, they can rely on the fact that only the results that are usable for their device will be shown.

Web Links

Category

Related Articles