What is Vary Header?

What is the Vary Header?

Understanding the Vary Header in VergeCloud

The Vary header is a critical HTTP header that helps configure content caching based on specific request conditions, such as browser type, encoding support, or user preferences. With VergeCloud's advanced CDN capabilities, proper configuration of the Vary header ensures that the content served is always appropriate for each user request, preventing issues like incorrect caching and optimizing user experience.

How the Vary Header Functions in VergeCloud

The Vary header tells VergeCloud’s CDN servers to examine certain request headers when receiving a user request. This ensures that the correct version of content is fetched and served based on request conditions. For example, imagine two browsers: one supports Gzip compression, and the other does not. With VergeCloud, if the edge server receives a request and the response from the origin server includes the Vary header with the Accept-Encoding value, the server will check the user’s request and deliver the appropriate version of the content based on their request headers.

Possible Vary Header Values in VergeCloud

The Vary header can include one or more request headers, and VergeCloud's CDN uses this information to determine which cached content to serve. Below are some common and important Vary header values and their usage with VergeCloud:

  • Accept-Encoding:

    This value differentiates content based on the compression method supported by the user's browser. For example, some browsers support Gzip or Brotli compression, while others may not. With VergeCloud, if the user requests compressed content and the edge server has a cached version that matches the requested compression, it will serve that version. If not, VergeCloud will request the content from the origin in the required encoding format.

  • User-Agent:

    The User-Agent header helps identify the client’s browser or device type (e.g., mobile, desktop, or specific browser). With VergeCloud, if your website serves different content for various devices (e.g., mobile-friendly versions for mobile devices), this header is useful for determining whether the cached content should be served to mobile or desktop users.

  • Accept-Language:

    The Accept-Language header tells the server the preferred language of the user, which VergeCloud can use to serve content in the user’s preferred language. For example, if your website has different language versions in English, Spanish, and French, VergeCloud ensures the correct language version is served to the user based on this header.

  • Cookie:

    The Cookie header can differentiate content based on user-specific session data or preferences stored in cookies. VergeCloud uses this capability to serve personalized content, such as user-specific recommendations or logged-in states, ensuring that the correct version of the content is delivered to users with unique sessions.

  • Authorization:

    The Authorization header differentiates between authenticated and unauthenticated users. This is crucial when serving different content to users based on their login status. For instance, authenticated users may see personalized content, while unauthenticated users will receive a generic version. VergeCloud can ensure the appropriate content is cached and served according to these conditions.

  • Host:

    The Host header distinguishes content based on the requested domain or subdomain. If you are serving content for multiple domains (e.g., example.com and example.net), VergeCloud’s CDN ensures the correct content is served based on the requested host, even when multiple sites are hosted on the same server with different domain names.

  • X-Forwarded-For (or X-Real-IP):

    The X-Forwarded-For or X-Real-IP header helps identify the original IP address of the user, especially when your website is behind a reverse proxy or CDN like VergeCloud. This is useful for logging, geolocation-based content delivery, or serving content based on the user's geographical location. VergeCloud ensures content is delivered according to the user’s region or network configuration.

How to Configure the Vary Header in the VergeCloud Panel

If your website offers different versions tailored to specific browsers (e.g., one version for Android and another for iOS), you can configure the Vary header with VergeCloud by following these steps:

  1. Log into the VergeCloud user panel.
  2. Go to the Content Delivery Network (CDN) section.
  3. Click on Page Rules.
  4. If applicable, click on the Edit Rule option.
  5. In the opened window, navigate to the Caching Settings section.
  6. Set the Cache Operation Level to QueryString+Cookie Included mode.
  7. Check the box for the Include Vary option.

After completing these steps, VergeCloud will ensure that different versions of your site are cached on its edge servers, delivering the appropriate content based on the user's browser or other request parameters.

    • Related Articles

    • Understanding the Set-Cookie Header

      Understanding the Set-Cookie Header and Caching Behavior The Set-Cookie HTTP response header is used by servers to store cookies on the user's browser. These cookies enable stateful sessions, user personalization, and authentication workflows. ...
    • What is the Host header?

      Understanding the Host Header The Host header is a mandatory HTTP request header that specifies the domain name (and optionally the port) of the target server. It plays a fundamental role in HTTP/1.1, as it tells the server which site or application ...
    • What is the Cache-Control Header?

      Understanding the Cache-Control Header in VergeCloud The Cache-Control header is an essential HTTP header used to manage caching behavior for content served on the web. By defining caching directives, the Cache-Control header helps optimize content ...
    • Understanding VergeCloud CDN Headers

      Intoduction When a website utilizes VergeCloud CDN for performance enhancement and security, visitor requests are directed to VergeCloud’s CDN servers instead of directly reaching the website's main server. In return, the CDN edge server sends ...
    • How to Create PEM File?

      PEM File Format Overview PEM, which stands for Privacy Enhanced Mail, is a widely used file format for storing and transferring encrypted data, particularly certificates and cryptographic keys. A file with a .PEM extension serves as a container for ...