njdancer
njdancer
CDCloudflare Developers
Created by njdancer on 10/23/2024 in #workers-help
Workers returning cache hit for 500 response without cache headers
I would appreciate any documentation you could link that describes this. I don't know what else to tell you other than thats what we experienced. Both with this particular 500 response and with the site in general. We originally didn't have the cache implementation I linked above and were just returning cache-control headers. This seemed to result in our function being called for every request. After adding the cache usage cf-cache-status headers were being added to the response.
5 replies
CDCloudflare Developers
Created by njdancer on 10/23/2024 in #workers-help
Workers returning cache hit for 500 response without cache headers
So I'm just trying to understand why the cache-headers within the response that is being cached(or lack-thereof) are not being respected. There are some default cache behaviours for http status codes but 500 does not seem to be included according to the documentation.
5 replies
CDCloudflare Developers
Created by njdancer on 10/23/2024 in #workers-help
Workers returning cache hit for 500 response without cache headers
As a workaround, we have also updated our cache logic to not put a response into cache if the status is > 500. With this change only, we are no longer seeing a cf-cache-status header on this response and the error condition does not persist past the API outage.
5 replies
CDCloudflare Developers
Created by njdancer on 10/23/2024 in #workers-help
Workers returning cache hit for 500 response without cache headers
Thanks for the response @Leo. How am I double proxying? Our DNS is not managed by cloudflare so the domains are not be proxied via the CDN. This testing has been done directly on a pages.dev domain. Prior to the usage of the cache api within our function, we were adding Cache-Control headers to our responses from our application. It then seemed (due to a lack of cf-cache-status) headers that these were not having any impact. As far as I'm aware a worker runs before the cache and therefore any caching that is required must be done manually in the worker function as we have done.
5 replies