Detect server response before caching page

I’ve created a page rule to cache a static page:
Cache Level: cache everything
Edge Cache TTL: 2 hours

There’s generally no problem, but several times the server has returned an error, or there’s been a connection timeout, and Cloudflare has cached this result. How can I test for a 200 before caching the response?

This doc tells you how long certain http status pages are cached for:

  • We will default to the following TTL depending on the return code:
200 301    120m;
302 303    20m;
403        5m;
404        5m;
any        0s;

I believe timeouts are in the 5xx range. They should not be cached.

It looks like the server actually returned a blank page with a 200. So that’s valid to cache, but technically broken! Any ideas how to detect this?

The server didn’t respond with an error code so there is no way for CF to assume a blank page was not the intentional output.
You’ll have to fix this issue on the server.

This topic was automatically closed after 30 days. New replies are no longer allowed.