Why Cloudflare-CDN-Cache-Control Disappears?

Hi,

Currently I am using Pro Plan.

I set the “Browser Cache TTL” to 5 days. However, this will cause 404 error being cached for 5 days as well. And in Pro plan, I cannot set a rule based on status code.

So, I try to add the following line in the .htaccess, to set Cache-Control, CDN-Cache-Control and Cloudflare-CDN-Cache-Control for 404 status code:

#  Set Cache-Control, CDN-Cache-Control and Cloudflare-CDN-Cache-Control for 404 not found error
Header set Cache-Control "max-age=180, must-revalidate" "expr=%{REQUEST_STATUS} == 404"
Header set CDN-Cache-Control "max-age=180, must-revalidate" "expr=%{REQUEST_STATUS} == 404"
Header set Cloudflare-CDN-Cache-Control "max-age=180, must-revalidate" "expr=%{REQUEST_STATUS} == 404"

I test the response code with a site not cached by Cloudflare(Test URL= http://www.sybase-recovery.com/my-not-found1), and three headers are all set, as below:
2021-11-25_10-40-37

However, if testing with a site cached by Cloudflare(Test URL=https://www.datanumen.com/not-found2), then Cloudflare-CDN-Cache-Control header will disappear, as below:

alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400
cache-control: no-cache, must-revalidate, max-age=0
cdn-cache-control: max-age=180, must-revalidate
cf-apo-via: origin,resnok
cf-cache-status: MISS
cf-edge-cache: cache,platform=wordpress
cf-ray: 6b3fdf12dbd76efb-BOM
content-encoding: br
content-type: text/html; charset=UTF-8
date: Fri, 26 Nov 2021 03:01:18 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expires: Wed, 11 Jan 1984 05:00:00 GMT
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
referrer-policy: no-referrer, strict-origin-when-cross-origin
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=jRvYXylodlG0k%2FVBX0tmjp76lm2w1ccsVPb%2Fp%2BnkUa9cBiyFKczivm%2FWvzGVE5t3Tztt%2BpBCig9LY1rqsd77MX4J4t%2F7EB4w9ykzEYqFWDgkaZB2JyP5N5795J6wgbwUwqAU"}],"group":"cf-nel","max_age":604800}
server: cloudflare
strict-transport-security: max-age=63072000
vary: Accept-Encoding,User-Agent
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block

Why?

It’s only meant for passing to CF edge server after which CF edge will remove it for end users. See https://blog.cloudflare.com/cdn-cache-control/

Return the Cloudflare-CDN-Cache-Control response header. This results in the same behavior as the origin returning CDN-Cache-Control except we will NOT proxy Cloudflare-CDN-Cache-Control downstream because it’s a header only used to control Cloudflare.

@eva2000 , OK. I see. Thank you very much.