Cloudflare does not Serve Stale when HTTP responds with Error 508

Have tested on php with http_response_code(508);
Cloudflare will serve with EXPIRED and serve the error page instead.

Tested with http_response_code(500);
Cloudflare serves the page from cache with STALE in cf-cache-status.

Question is why is 508 error not served from stale when it is technically an error from origin?
Origin Cache-Control is stale-if-error=86400

The docs under the revalidation section describes quite a few possible cases where stale-if-error does not apply:

The stale-if-error directive is ignored if Always Online is enabled or if an explicit in-protocol directive is passed. Examples of explicit in-protocol directives include 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.

Does any of these cases apply to the URL you are referring to?

1 Like

None applies, max-age=60 for testing and Always Online specifically disabled for this use case.

Hence, the full cache-control header is public, max-age=60, stale-if-error=86400

To reiterate, it served cached stale for Error 500, not for Error 508.

Thanks for clearing things up.

Ok, could you please open a ticket and post it here?

I don’t have the ability to create a ‘Technical Problem’ support ticket on the Free plan.

Thanks for the reply, I will try do escalate this, since it seems to be a bug, or at least a not expected behaviour.


Can you tell us which URL gives this issue. Unfortunately I am unable to proceed further without much details


It’s not a specific URL in a sense, it is more of an actual Error 508 from origin happening, and stale-if-error did not serve a stale cached page.

I tested with PHP by simulating an internal page to output 508, I did not get the cached page served. The page was cf-cache-status: HIT before origin cache-control times out, i.e. max-age=60

Would you be able to provide them with such an URL, where you simulate the Error 508, so they can run their tests against this URL and monitor it?


1 Like

You may debug using


You may set http_response_code(n) via the ?http=n query string

The cdn-cache-control parameters are exaggerated with max-age=1, and have tested that that HTTP 500 works for stale serving, 508 shows the error page.

I’m using cache-control: max-age=0 to trigger cache revalidation with Cloudflare from browser-side.

True, I tested:

    Status Code 200 (stale cache with “Test” is displayed)

    Status Code 508 (no stale cache is displayed)

1 Like

Sorry to bump, my site did momentarily went into Error 508.

Confirmed that a natural and non-simulated Error 508 did not get cache served stale.

Really hope this can be mitigated because it really defeats the purpose of having a CDN for service redundancy…

Can you try removing all page rules that would interact with your test URLs and confirm the issue persists?

Can you also try turning off origin cache control as well? Based on our documentation at I believe this is expected if origin cache control is enabled:

1 Like

Appreciate the reply, have tested using the following rules per your suggestion;

  • Cache Level: Cache Everything
  • Origin Cache Control: Disabled

Error 500 returns a STALE cache as expected, however Error 508 continues to return a HIT/MISS displaying the origin’s Error page…

Hello there,

In this case, we should consider the cached asset for the 508 response, which would be served expired, since the origin is reachable and the 508 response exists in the cache. (Another note, is that the behavior for 508 responses isn’t customized as for 500-504, this 508 was cached due to the cache everything page rule)

If the cached asset was a 200 response, and then the server returned a 508 error, then we should be serving a stale response.

I cannot test this as with the cache everything enabled, since each URL is considered separately for caching, so ?http=508 is a different cached asset, than ?http=508 or ?http=200.

Could you open a ticket and reply to this thread with the ticket number? [email protected]

Regarding origin cache control, due to the CDN-Cache-control directives, cache-control shouldn’t be considered by the Cloudflare cache.

CDN-Cache-Control · Cloudflare Cache docs

Return the CDN-Cache-Control response header which Cloudflare evaluates to make caching decisions. Cache-Control , if also returned by the origin, is proxied as is and does not affect caching decisions made by Cloudflare. Additionally, CDN-Cache-Control is proxied downstream in case there are other CDNs between Cloudflare and the browser.

However, the cache-control could influence the cache-control response from Cloudflare to the client.

1 Like

Is the behaviour that @user18298 is reporting by design, and a 508 is not expected to trigger stale-if-error.

The RFC for stale-if-error states that:

an error is any situation that would result in a 500, 502, 503, or 504 HTTP response status code being returned.


If the cached asset was the 508 Response itself, then Cloudflare will revalidated the 508. So the tests we’ve done to this point against, are expectedly returning that 508 response.

Now, the behavior that the user asking about is what asset would be delivered for functioning page (no error response), that then returns a 508 error.
In this case, I would agree the expected behavior would be a stale asset, but you’d first need to confirm that the asset is in the cache by first seeing a cf-cache-status HIT on a different non-error status. This can’t be achieved with the URL above, or similar tests, due to Cache Everything caching query strings separately.


I’ve created a ticket; #2375355.

The page’s code has been updated to simulate Error 508 whenever the current time minute is even number, to eliminate the usage of the query string as suggested.

Otherwise it should output an ‘OK’ with 200.

Have also cleared the cache of the page just in case.

1 Like

Sorry to bump, is there any resolution or solution?