Bypassing Cloudflare Cache

#1

Hey,

(how) is it possible to bypass the Cloudflare cache (which has a rule for “Cache Everything” set) for specific requests with a worker?
e.g. if IP is xyz I want to always go to origin (I found examples how to block, but no examples how to bypass the cache)

Additionally, the Cache Everything rule will also apply to requests fetched by a worker? This means that any request I fetch with a worker, the page rules will apply & cache it, correct?

#2

I can’t recall now exactly how to invalidate the cache, I know there is a way, but maybe someone remembers how…

For the Worker I can tell you that it always runs, there is no way to cache it.

#3

fetch(request, { cf: { cacheTtlByStatus: { "200-299": -1, 404: 1, "500-599": 0 } } })

2 Likes
#4

Thanks, thats how I can not cache the response, but the question is:. how to bypass the cloudflare cache for specific requests (if that page is already in cloudflare cache)

Normally:
Request => Cloudflare Worker => Cloudflare Cache => Origin

With my worker
if IP === 1234 {
Request => Cloudflare Worker => Origin
}