503 got cached by worker

Hi,

We’re using Cloudflare Workers to serve our static assets. The origin is Google Cloud Storage.

Today, our site went down because our JS bundle continuously returned 503 until we did a rollback which changed the JS bundle. I investigated the incident and noticed that the cache statistics clearly show the errors and that most of the requests were cache hits. My conclusion is that Cloudflare had cached a (temporary) 503 returned by Google Cloud Storage.

Our worker is using “cacheTtl: 31536000” to allow infinite caching because the files are considered immutable. I see that “cacheTtlByStatus” is only available to enterprise customers. Is there a way to still use “cacheTtl” in a safe way? There is always the risk that the origin server returns 503 for whatever reason, which should not poison the cache.

Best,
Richard