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 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 ...
    • VergeCloud’s X-Cache and X-Time Headers Explained

      Once VergeCloud's CDN service is activated, the system includes the x-cache and x-time headers in the responses to user requests. What Does X-Cache Mean? The x-cache header can have several possible values: MISS, HIT, and BYPASS. MISS: The requested ...
    • Understanding Cross-Origin Resource Sharing (CORS) and Its Configuration.

      Cross-Origin Resource Sharing (CORS) Header Cross-Origin Resource Sharing (CORS) is a critical web security feature that allows servers to specify who can access their resources and how those resources can be accessed. By defining CORS policies, you ...
    • Understanding HSTS (HTTP Strict Transport Security) and How to Enable It on VergeCloud

      What Is HSTS (HTTP Strict Transport Security)? HTTP Strict Transport Security (HSTS) is a security feature that forces web browsers to connect only via HTTPS for a specified duration. Once the browser learns about HSTS from a site, it upgrades all ...
    • Understanding Content Security Policy (CSP) and Its Directives.

      Content Security Policy (CSP) Header The Content Security Policy (CSP) header is a robust web security feature designed to prevent a variety of attacks, including Cross-Site Scripting (XSS), clickjacking, and other code injection threats. By defining ...