Result:
During cache expiration, duration of request takes additional 5 seconds, so Cloudflare NEVER provides stale content while revalidation.
Additional info:
Removing stale-while-revalidate from cache-control header hasnt any impact on flow what mean Cloudflare doesnt support this feature at all.
Cloudflare may override your cache-control header when a Browser Cache TTL is set for any amount of time. To avoid this, you need to set it to Respect Existing Headers in the Dashboard > Cache app.
Also, if you use the Origin Cache-Control setting via page rule, this page explain some details about specific conditions that will make Cloudflare ignore "stale-while-revalidate’.
Cloudflare attempts to revalidate the content with the origin before serving the response to the client.
I’m not sure but my question is, what is purpose to using stale-while-revalidate if user must wait for revalidated content? Revalidation will occurs in background as name of header (“stale-while-revalidate”) suggests?
It is proper implementation on CF side?
Have you enabled origin cache control as shown in the screenshot in the article @cbrandt linked to? Also Edge Cache TTL needs to not be enabled.
Interaction with other Cloudflare features
Edge Cache TTL
Edge Cache TTL page rule settings override s-maxage and disable revalidation directives if present. The original Cache-Control header is passed downstream from our edge even if Edge Cache TTL overrides are present.
“Always online” disabled, origin cache control was enabled, edge cache ttl was disabled, proper headers was set on my server side.
I understand most of threads on Cloudflare community comes from people which has problems even with proper configuration but I dont have problems with configuration, I have problem with not working feature.
A cache MUST NOT generate a stale response if it is prohibited by an explicit in-protocol directive (e.g., by a “no-store” or “no-cache” cache directive, a “must-revalidate” cache-response-directive, or an applicable “s-maxage” or “proxy-revalidate” cache-response-directive; see Section 5.2.2).
If you remove s-max-age from your header does the feature work as expected?
+1 My company is looking to implement SWR. Please follow up if this issue is resolved.
@mdee@cbrandt@cs-cf
Looks like nobody’s interested in resolving this issue.
If there is no update during my product development, then I will leave from support cloudflare for users of my product.