Search code examples
azurecachingcdnhttp-cachingazure-cdn

Azure CDN Url rewrite is not cache friendly


I'm trying to setup Azure Standard CDN on top of another CDN (don't ask) and I have the following rewrite url action to map paths:

enter image description here

It's working but Azure CDN doesn't cache the responses even if I have the second action with an explicit cache override. Query string caching behavior setting in my Azure CDN is set to "Cache every unique URL". What am I missing?

Here is the response headers I get:

HTTP/2 200 OK
cache-control: private, no-transform, immutable, max-age=604800
content-length: 48247
content-type: image/jpeg
last-modified: Thu, 18 Jun 2020 10:40:13 GMT
accept-ranges: bytes
etag: "ca5d81db6ff9266ad8fb95bc0e0daf33"
vary: Accept,User-Agent
server: Cloudinary
x-cache: TCP_MISS
x-request-id: b2bc7991c7f737acf00e07627c4e0d9a
strict-transport-security: max-age=604800
server-timing: fastly;dur=1;start=2020-06-18T17:34:56.853Z;desc=hit,rtt;dur=1
timing-allow-origin: *
access-control-allow-origin: *
access-control-expose-headers: Content-Length,ETag,Server-Timing,Vary
x-azure-ref-originshield: 0wKXr....
x-azure-ref: 0wKXr...
date: Thu, 18 Jun 2020 17:34:56 GMT
X-Firefox-Spdy: h2

cache-control is set to 7 days (the origin CDN default) and Azure's x-cache is always TCP_MISS :(


Solution

  • Got a response from Microsoft support:

    a web page response marked as private can be cached by a desktop browser, but not a content delivery network (CDN).

    Basically, Azure CDN respects cache-control: private and doesn't allow to change the behavior. The only option is to modify the origin response.