Need help with caching setup

I am an enterprise customer who made a ticket 2 weeks ago with no response so I am asking here. my platform uses content-type headers in our api responses to tell customers applications interacting with our platform how to interpret the file. so some may say application/json or image/png depending on what the customer is embedding, however they have no file extensions so cloudflare considers them dynamic. is there a blanket way to say that for domain.com/api/** (where there could be literally any amount of subdirectories) to use the content-type header to determine whether to cache instead of being dependent on the file extension? for clarity google cloud cdn handles this without issue.
4 Replies
threekat
threekatOP16mo ago
Default Cache Behavior · Cloudflare Cache (CDN) docs
Cloudflare respects the origin web server’s cache headers in the following order unless an Edge Cache TTL page rule overrides the headers.
threekat
threekatOP16mo ago
I think i am misunderstanding what that does because my understanding of cache keys is page rules set the cache key as part of the response to the client. so if i am defining the content-type header at the source of the api it's not using that to determine whether the content should be cached or served dynamically what i am trying to do is instruct cloudflare to use the content-type header rather than the file extension to determine what to cache for anything in the api and the content all has cache control at the source, so the api should be telling cloudflare how long to cache the response 2941264
threekat
threekatOP16mo ago
i ended up setting this rule and i think its working
No description
threekat
threekatOP16mo ago
i'm just afraid of cloudflare overriding the cache response for json thank you!

Did you find this page helpful?