Cache everything except no-cache

i want to cache everything that cache control is not on no-cache but i dont see how
11 Replies
glacinefrox
glacinefroxOP•8mo ago
this is my cache rule i just want to cahce the things that his cache-control is not to no-cahe is that so dificult?
Cyb3r-Jak3
Cyb3r-Jak3•8mo ago
I am confused. You want to cache things that have a cache control header and ignore if it doesn't?
glacinefrox
glacinefroxOP•8mo ago
i want to cache everything except the ones that have nocache
res.set({
'Cache-Control': 'no-cache'
});
res.set({
'Cache-Control': 'no-cache'
});
DarkDeviL
DarkDeviL•8mo ago
Try "no-store" instead.
glacinefrox
glacinefroxOP•8mo ago
I Will try thx can i do no-cache no-store no-transform ? cloudfare does what it wants and auto modifies it to that here is my rule @DarkDeviL
DarkDeviL
DarkDeviL•8mo ago
That depends what exactly you want to do, ... "no-cache" actually allows caching, but requires re-validation every single time, which is why I suggested you to try "no-store", according to your explanation. If you want to mix multiple options, you can do so, but would need to comma separate, e.g.:
Cache-Control: no-store, no-transform
Cache-Control: no-store, no-transform
Given this rule, I would say that: max-age=2678400 here would appear to come from your origin.
glacinefrox
glacinefroxOP•8mo ago
how should my cache rule should be
DarkDeviL
DarkDeviL•8mo ago
That would depend on what exactly you're looking to do. And whether you want your origin to control it using e.g. Cache-Control as it seems like you've been trying to. Or if you would just let Cloudflare handle it for you (and thereby ignore e.g. the Cache-Control from the origin). Your check mark on "[x] Use cache-control header if present, bypass cache if not" suggests that you want to control the cache from your origin with Cache-Control, and if there are no Cache-Control set from the origin (or any intermediate between Cloudflare and the origin), you do not want Cloudflare to cache the content.
glacinefrox
glacinefroxOP•8mo ago
AND IF i want to store it cause i want to store all except the ones with no-store that could work too if cache control is not sent dont cache if it is cache for 4 hours so it should be like this
DarkDeviL
DarkDeviL•8mo ago
To cache for 4 hours, with the above setting, you would need to set something like e.g. "Cache-Control: max-age=14400" or "Cache-Control: s-maxage=14400" from your origin, for those things that yo want to cache for 4 hours (14400 seconds). If your origin (the server behind Cloudflare) sends "Cache-Control: max-age=2678400" to Cloudflare, like it appears above, then you're instructing Cloudflare to cache it for 31 days.
glacinefrox
glacinefroxOP•8mo ago
i think you saved my life 🥹
Want results from more Discord servers?
Add your server