Using cache put and match in the same worker
Hello,
As the title says, I want to cache something and verify it's there. This works just fine in wrangler dev but not in prod. Is this possible? Am I missing something simple?
Playground:
http://tinyurl.com/3zax9ms7
12 Replies
Not sure if related to your issue, but this is not expected to work in Playground:
However, any Cache API operations in the Cloudflare Workers dashboard editor, Playground previews, and any *.workers.dev deployments will have no impact.(from https://developers.cloudflare.com/workers/runtime-apis/cache/)
@geomaster oh thanks, I didn't think about that for playground, but it definitely doesn't work with a production deploy
https://pwsh-gallery-preview.jwg.workers.dev/az.accounts/page/recent.json
This same function works just fine when running wrangler dev locally
There's no cache on workers.dev either
only Custom Domains
I'd guess because the way the cache is abstracted to the sqlite database in the local runner doesn't behave exactly as the local one
Derp! I forgot about that!
Thanks, I'll deploy a custom domain for that
I'd question if that would work anyway though, I would have thought cache needs valid URLs i.e
https://test.invalid
@Chaika it'll throw an exception if put doesn't like the uri
Might be fine. I've just never tried it without a valid url before. It'd be easy to try that as well if it doesn't work on a Custom Domain though
In my non-dashboard prod code it is a valid URL in the same custom domain
it uses the request URL as the base
I basically need to do a heavy fetch in the backend and I want to pre-populate some cache URLs for fetches that will occur after that initial heavy requests
@Chaika thanks for your quick eyes! Appreciated
Is there a way to mark as answered in this forum?
ah it worked on a Custom Domain?
I guess the solved tag is it
Yea you can just add the Solved tag
haven't tried but I'll bet for sure that was it, I'm doing it now but I have to set up the custom domain first
@Chaika that worked:
https://preview.pwsh.gallery/Az.Accounts/page/recent.json