Workers fetch cache not working?
I'm using an external api, which is rate limited. But I need more requests than that the limit allows, therefore I want to use cloudflare workers to cache the request and work as a middle man. I'm using the
hono
framework to handle my requests (but I don't think that should affect this issue). I'm using this function to cache my requests.
But when runnin this, I'm still getting rate-limited by the external api? Even tough 1 hour is plenty below the rate limit?4 Replies
Cloudflare's cache doesn't guarantee that the data will stay there for 1 hour. The one hour will just be the maximum time. Are the requests actually coming from cache (they should have a
CF-Cache-Status
header, and if it was in cache it will return HIT
)? If you want to guarantee that the data will be still be there in an hour, you need to use something like KV.
These are the headers that are present on the response, so the cf-cache-status is present but set to dynamic. Also what do you mean with HIT?
If it was getting it from the cache that header would be set to "HIT". You might want to use the cache API here, or use KV.
Alright ^^