Cache level Standard

I have set standard mode in a page rule, but I am quite uncertain what it does. I can read in the docs that it “Delivers a different resource each time the query string changes.”, but I have no querystring. Does this mean that an url without querystring doesn’t get cached, or does it mean that an new resource can be requested whenever changing (or adding) a querystring?

I have understood it that it caches forever, or until it a querystring is added/changed. I have tried to update the resource on the origin server. It serves modified tags, and etags. It looks like the “forever caching” is more like “until a querystring is added or modified OR a timestamp/etag changes”, because after some time (a hour or two) the updated gets served through Cloudflare, with an “EXPIRED” header attached.

I have also seen that with a page rule set to cache at the edge, caches 404 for as long as the ttl is alive, but only if i change to cache level standard mode (and delete the edge ttl rule) it caches 404 for 5 minutes and then tries at origin again. Is this expected? Shouldnt the edge caching do the same, with the 5 minutes cooldown, or is it only for standard mode?

Am I all wrong here, or maybe i am using it incorrectly?

It means for each different query string there will be a cached file after the first visit. An URL without a query string will be one of the various cache-able URLs. Imagine a JS file that is part of a plugin. The plugin is updated and it adds a query string to add the version number of the JS file.

Each will have their own cached file after they are first requested. The HTML will now only request the newer version, and there’s no risk of the old JS file being served. If you were to use “Ignore Query String” as your cache level, CF would keep the ver=1.00 file on cache until expiration, and the new version, though requested, wouldn’t be served.

As for “cache forever”, no! Cloudflare only caches files for the higher value between the TTL set at the origin and the TTL set with an Edge Cache TTL setting. And that only (1) after the file is first requested by a visitor, (2) for a specific datacenter, and (3) for as long as Cloudflare doesn’t purge it in case it doesn’t have enough requests.

The 404 TTL is the expected, default behavior, barring a “cache everything” page rule.

I must be doing something wrong. I have a page rule with Cache Level set to standard. Only then Cloudflare doesn’t cache 404 for more than five minutes. If I add an Edge TTL to it, the 404 gets cached for the duration of the edge TTL. As I understand your answer I need to add a Cache everything to it, and first then the 404 gets cached for 5 minutes only?

What I want it actually pretty simple. I want a page rule that caches for a long time, because it serves images that never changes, but doesn’t cache 404 more than a few minutes. I thought an edge TTL with fx 7 days was sufficient at first but that caches 404. When I remove it and add a cache level standard, it does the 404 correctly.

Oh, you wrote barring a cache everything rule. Well it sounds like what I want to do isn’t possible. If I only select the standard mode then my server gets hit on resources when they don’t have a lot of traffic and I don’t want that.

You could try redirecting your 404s at the origin to a URL that’s outside the scope of the cache-everything page rule.

Otherwise, you could also set your origin with a no-cache directive, as explained in this response to a similar request:

But I like the 5 minute 404 rule. I only want CF to cache it for a short periode of time and the ask my origin again. I can only manage to get this to work with a cache level: standard. When I add Edge TTL to the rule the 404 gets cached the time the TTL is set to. As I understand by your answers, this is the expected behaviour.

You could then invert the TTLs, and set the longer TTL for HTML and images at your origin, with the desired long period, and not set the Edge Cache TTL at the page rule. Without he Edge Cache TTL, Cloudflare will only override the origin when the TTL set at CF is longer than that set at the origin, according to the documentation I linked to above.

I can see that. Thanks. How long will CF cache if I don’t explicitly specify it either through edge cache TTL or origin cache header? Or is there no specific time, and only “if it gets requests enough”, else it expires. Does it respect etags, and sends if-not-modified to check at origin?

The page I linked to previously has a table at the end, 120 min for 200, 5 min for 404 etc.

No matter what the caching period, either the CF default, or some TTL set at the origin or with an Edge Cache TTL, CF may purge the cache if the file is requested infrequently. You can set a page monitor to check your page every hour, for instance, to keep your cached files from expiring, in case the URL has low demand.

As for etags:

Oooh. Sorry. The page you linked to I did read. That was were I got the five minutes on 404 from I have completely missed the 200. Sorry. So by applying cache level standard and no edge cache TTL or origin TTL, the resource is cached for 2 hours on 200, and 5 minutes for 404. If I apply edge cache TTL or an origin cache TTL a 404 and a 200 will be stored in CF for the duration of the TTL and thereby overrules the default 5 minutes on 404. Is that correctly understood?

That’s also my understanding. But with Edge Cache TTL, as your experience shows, you can only set one value for both 200 and 404, while at the origin you could set different values for 200 and 404.

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