Open In App

HTTP headers | Vary

The HTTP Vary header is a response-type type header. It is used to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm and determines how to match future request headers to decide whether a cached response can be used rather than requesting a fresh one from the origin server. If you want to serve different content for the mobile users, then it can help to avoid that a cache may mistakenly serve a desktop version of your site to your mobile users. It will help search engines to discover the mobile version of a page.

Syntax:



Vary: *

OR

Vary: <header-name>

Directives: There are two directives accepted by HTTP headers Vary.



Example:

Vary: Accept-Encoding
Vary: User-Agent

To check this Vary in action go to Inspect Element -> Network check the response header for Vary like below, Vary is highlighted you can see.



Supported Browsers:
The browsers compatible with HTTP headers Vary are listed below:

Article Tags :