How can I cache 500 errors?

Presently I have the following settings:

  • For url*, cache level = “Cache Everything”
  • For url*, browser cache TTL = 30 minutes
  • For url*, edge cache TTL = 2 hours
  • For URI path containing “/”, set static header “Cache-Control” = “public, max-age=3600”
  • For URI path containing “/”, remove header “Date”
  • Caching level = “No query string”
  • Browser cache TTL = “4 hours”

However the following URL:
notdevtools DOT COM /devtools/third_party/intl-messageformat/package/

Always returns cf-cache-status = "STALE" (and I can confirm it is hitting my backend origin).

I can’t see anything in the response of my origin that would prevent caching, but… it still isn’t caching.

And the response my server gives is:

Request Method: GET
Status Code: 500 “Error: ENOENT: no such file or directory, stat ‘/root/new-site/dist/devtools/third_party/intl-messageformat/package/’”
Remote Address:
Referrer Policy: strict-origin-when-cross-origin

CDN-Cache-Control: public, max-age=3600
Connection: keep-alive
Date: Tue, 09 Aug 2022 14:29:50 GMT
Keep-Alive: timeout=5
Transfer-Encoding: chunked
Vary: Origin

Any help would be very much appreciated!

Enterprise plans can cache by status code:

There’s also a bit more on that page about doing it with a Worker, but I don’t know if plan level matters.

Oh, sorry if I was unclear. I also want to cache 200 responses, etc. I want to cache all responses, and most do appear to be cached, it is only 500 responses which aren’t getting cached.

Ah, I read that page more. It looks like I am doing that already, as per Set cache TTL by response status via the Cloudflare dashboard, I override the cache TTL, which appears to be what this page is describing.

The problem appears to have fixed itself, with no configuration changes on my part.

I assume Cloudflare somehow cached the TTL or non-cache state of the resource, re-requesting the resource without updating this state. I would assume if it was missing the cache anyway all configuration changes would immediately apply, but this does not appear to be the case.

Is it transform URL - is it request headers?
Does that actually work :eyes:. Because recently when i configured it, it wasn’t working :skull:

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