azurecdnazure-cdnazure-front-door

Azure Front Door Premium and Vary response header


I'm using Azure Front Door in Premium Tier. I have caching enabled on my route (CDN).

I have some troubles, which seems to be the result of the fact that CDN ignores the Vary header.

I have made this test:

C:\Users\TomaszMadeyski>curl -H "Next-Url: 123" -sS -D - https://my.page.at.frontdoor.com -o /dev/null
HTTP/1.1 200 OK
Date: Fri, 12 Jul 2024 09:59:38 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
cache-control: public, max-age=3600, stale-while-revalidate=3600
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url
x-azure-ref: 20240712T095938Z-1688db7465dw7s2w5364ydfyf4000000062g00000001m8hq
X-Cache: TCP_HIT
x-fd-int-roxy-purgeid: 37
X-Cache-Info: L1_T2

curl: (23) Failure writing output to destination, passed 11365 returned 4294967295

C:\Users\TomaszMadeyski>curl -H "Next-Url: 1234" -sS -D - https://my.page.at.frontdoor.com -o /dev/null
HTTP/1.1 200 OK
Date: Fri, 12 Jul 2024 10:02:34 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
cache-control: public, max-age=3600, stale-while-revalidate=3600
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url
x-azure-ref: 20240712T100234Z-1688db7465djbxcc9gu32zk19800000006eg000000001ytv
X-Cache: TCP_HIT
x-fd-int-roxy-purgeid: 37

As you can see in the response I have Vary header, one of its values is Next-Url. So I would expect not to get TCP_HIT response from CDN while I specify different values of Next-Url header.

My conclusion: Vary header is ignored by Front Door's CDN.

Is this wrong conclusion? Is there a way to make Front Door's CDN to respect the value of Vary header?


Solution

  • Azure Front Door Premium and Vary response header

    Currently, Azure Front Door does not honour the "Vary" header. it means that if any response with a "Vary" header which adds unique request header, such as Next-Url. by default, the CDN does not support cache response separately for each value of that header. Instead, it will cache the response based on the other cache control headers, such as "Cache-Control" and "Expires".

    This will impact by unexpected caching behaviour if your application depends on the "Vary" header to serve different responses depends on the value of a specific request header.

    Note: Any headers forward to Azure Front Door from the backend are also passed through to the client.

    Refer:
    Does Azure Front Door Premium support "Vary" header ? by KapilAnanth-MSFT

    From the Front Door to the client