Exclude from Cache Based on Content-Type

Hello,

I am wondering if it’s possible to bypass the Cloudflare cache if the Content-Type of the request is “octet-stream”

So anytime the response is Content-Type: octet-stream I want to ensure that cloudflare does not cache the response.

I have so far been unable to find a way to configure something like this in the page rules.

Any help is appreciated. Thanks!

Workers could somewhat do that (maybe needs some workarounds), however it will be easier if you simply pass along an appropriate Cache-Control header with your content type.

For example

Cache-Control: private

I actually don’t have control of the Cache-Control header for the subdomain I’m working with since it’s going to a third party tool.

Seems like a worker is the only solution?

Thanks!

The other thing you could try is to add a random query string to the request. If you can’t do that either and the resource is cached by default you can only go the Worker route.

From what I know, Workers cannot really specify that the cache is to be skipped (contrary to them actually being able to force caching), hence the mentioned workarounds, but you could try to manually clear the cache via the caching API or change the query string, as just mentioned, so that the cache still does not apply.

This topic was automatically closed after 14 days. New replies are no longer allowed.