Cache HIT issue on no-cache pages

Hi, we have issue with cached private content, server headers are no-cache, no store:

HTTP/2 200 
server: nginx
date: Wed, 27 Oct 2021 07:57:07 GMT
content-type: text/html; charset=UTF-8
content-length: 163731
vary: Accept-Encoding
vary: Accept-Encoding
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
pragma: no-cache
expires: -1
cache-control: no-store, no-cache, must-revalidate, max-age=0
accept-ranges: bytes

but CF cached everything:

HTTP/2 200 
date: Wed, 27 Oct 2021 07:57:27 GMT
content-type: text/html; charset=UTF-8
cf-ray: 6a4a5fa52f2ed407-BUD
age: 6720
cache-control: max-age=14400, must-revalidate
expires: -1
last-modified: Wed, 27 Oct 2021 05:59:18 GMT
vary: Accept-Encoding
cf-cache-status: HIT
cf-apo-via: tcache
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
pragma: no-cache
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=WggrT5v%2Fw8p8hsTk0th1NOxU6QE3NVlNfyMj57HblPrQPqLWgnBBginCdNMPTB%2F8P5BcBbBvLQ%2BiV0D6Ty4GgVvdxZK7p%2B%2FJkmPiA2xFlrNf4KWPN73BhER7rG2R"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

rule:

We set cache level to bypass to prevent caching private content, but now static content is also not cached by CF. We have configured the same rule for another domain (origin server is the same, and headers…), but CF does not cache everything (works correctly).

Can there be a problem on the CF side? Or do we have something misconfigured? Thanks.

Like the image, the page rule rank is can move.

image

The order is likely to be incorrect.

How is the content set as private? I see you’re using APO, but if you have a special system in place that uses custom cookies, APO might not recognize those a cookies it should bypass cache for.

@Nakamura I don’t think so, because if I turn off rule, everything is ok.

@sdayman
from https://developers.cloudflare.com/cache/about/default-cache-behavior

Cloudflare does not cache the resource if the Cache-Control header is set to private , no-store , no-cache , or max-age=0 or if there is a cookie in the response

original response from server is cache-control: no-store, no-cache, must-revalidate, max-age=0, so if I’m right CF should not cache, or?

and we have same CF configuration (cache level: standard) on domain.com and domain.sk, but com cache everything while sk not… maybe some CF bug???

Are you still having this issue? I’m seeing a BYPASS for the home page and the other pages I checked.

At this point, I’m wondering why you’re using APO in the first place. By default, Cloudflare will not cache HTML, so you shouldn’t need any cache-related rules.

@sdayman
we have a bypass to prevent caching of everything, if we set the standard, CF will start caching all pages, but only on gymbeam.com, other domains gymbeam.sk, gymbeam.cz … are good. The rule is to cache static content using CF and APO is used for wp and magento.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.