Hi there,
We’re intermittently encountering an issue where Cloudflare is caching pages that returned 404 HTTP status codes and I’m wondering what the easiest way to deal with this. What happens is:
- We start a rolling release of our web app. The release contains some freshly compiled JS files that did not exist in the previous release.
- Someone visits our website while the release is running, and their request hits one of the pods with the new code. This code requests one of the new JS files.
- This request goes to one of the old pods, which does not have the JS file requested, and returns a 404.
- Unfortunately, this 404 response then gets cached by Cloudflare, so even once the release is done, some subset of users hit the Cloudflare cache and get 404s for the file that now exists on every pod.
What is the best way to deal with this? I can switch our code to stop performing rolling releases, but presumably there’s an easier way to prevent pages that return 404s from being cached at all.