I’ve setup a Page Rule to enabled Cache Everything / Origin Cache Control. In my application code I set a cache-control header, and CloudFlare properly caches the response.
However, in some cases an error is encountered outside the application code on my origin server, resulting in a 500/server error.
With Origin Cache Control enabled, CloudFlare will ignore any HTTP Status code, and only inspect your cache-control header it seems. So, this results in the 500 error being cached for just as long as a ‘good’ response.
Is there a way to tell CloudFlare to only use Cache-Control header when a 2xx is returned, to preventing caching when a 4xx or 5xx error is unexpectedly returned from server?