The Vary header is one of the significant HTTP headers. Setting this header is essential to make sure that the delivered content fits every browser. It determines that the CDN servers should consider the user request type to cache various contents and retrieve them in response to the request.

How Does a Vary Header Works?

The Vary header determines that when the CDN servers receive an end-user request, they must check which parts of the request headers to retrieve a suitable response accordingly.

For example, imagine that there are two browsers – one of which supports the Gzip, and the other one does not. When the edge server, for the first time, receives a request from a browser, it transfers the request to the central server that hosts the website. If the central server-side response includes the Vary header (with the accept-encoding value), then the edge server re-checks the request received from the user. On the other hand, if the client-side request does not include an accept-encoding header, but there is an unzipped version of the requested resource stored on the CDN edge server, then the server retrieves it to the user. However, if there is a header in the user request, the edge server checks its value, and whenever having a zipped version of the requested resource on its cache, the server retrieves it to the end-user.

How to Configure the Vary Header on the ArvanCloud Panel

If your website has several versions to suit users’ various browsers (for example, a version for Android users and another for iOS users), you can use the Page Rules section on the ArvanCloud user panel to define a rule and activate the Include Vary Header for every performance.

To do so, complete the following steps:

  • Open the ArvanCloud user panel,
  • Click on the Content Delivery Network (CDN) section,
  • Select the Page Rules,
  • Click on the Edit Rule option (if it exists),
  • On the open window, find the Caching Settings section,
  • Set the Cache Operation Level on the QueryString+Cookie Included mode,
  • Tick the Include Vary option.

Having done the preceding steps, you can make sure that different versions of your website are cached on the ArvanCloud edge servers so that each browser will be provided with suitable content.