Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

RihanArfan
Copy link
Contributor

@RihanArfan RihanArfan commented Mar 19, 2025

@pi0
Copy link
Member

pi0 commented Mar 19, 2025

Really smart approach. Honestly i'm not 💯 sure it would be best case of using unstorage (Nitro v3 rather can directly leverage caches API on top of web response handling)

But let's keep both on the track and tested.

@RihanArfan
Copy link
Contributor Author

If Nitro v3 can do cached event handlers and functions directly via the cache API then I think may not be necessary then 😄

Happy for you to close if Nitro is handling it better.

@pi0
Copy link
Member

pi0 commented Apr 2, 2025

@RihanArfan any update on this? (have you tested this solution on prod?)

@ascorbic
Copy link
Collaborator

ascorbic commented Apr 9, 2025

This isn't Cloudflare-specific. It's using the CacheStorage api, which is also supported by other runtimes too

@RihanArfan
Copy link
Contributor Author

@ascorbic Cloudflare's implementation of the Cache API is slightly different from the web standard - https://developers.cloudflare.com/workers/runtime-apis/cache/#accessing-cache

Most notably, there's no way to list all keys - https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/keys

@pi0 Unfortunately haven't been able to yet sorry

@ascorbic
Copy link
Collaborator

@RihanArfan is there a way to implement this in a cross-platform way though, that supports runtimes that implement the web standard too

@eduardoboucas
Copy link

@RihanArfan is there a way to implement this in a cross-platform way though, that supports runtimes that implement the web standard too

Netlify would also be interested in this.

@pi0
Copy link
Member

pi0 commented Aug 22, 2025

@RihanArfan do you remember what is last state of this? could we move it forward? (updated PR with refactors + tests but seems wrangler proxy is not implementing caches API at least out of the box)

@eduardoboucas while making this one generic could take time (or not be possible), if you have time to draft a driver for netlify, i can merge and release.

Copy link

codecov bot commented Aug 22, 2025

Codecov Report

❌ Patch coverage is 29.16667% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.83%. Comparing base (70310f9) to head (673b97e).
⚠️ Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
src/drivers/cloudflare-cache-binding.ts 27.14% 51 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #603      +/-   ##
==========================================
+ Coverage   59.99%   61.83%   +1.84%     
==========================================
  Files          42       44       +2     
  Lines        3657     3962     +305     
  Branches      590      661      +71     
==========================================
+ Hits         2194     2450     +256     
- Misses       1460     1509      +49     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pi0
Copy link
Member

pi0 commented Aug 22, 2025

Disabled tests with a manual test for now (works in prod sandbox with using unstorage:// as cache key)

@dario-piotrowicz @petebacondarwin could you please kindly review this PR and confirm if i am not mistaking and wrangler dev proxy does not implement caches API?

@dario-piotrowicz
Copy link

dario-piotrowicz commented Aug 27, 2025

Disabled tests with a manual test for now (works in prod sandbox with using unstorage:// as cache key)

@dario-piotrowicz @petebacondarwin could you please kindly review this PR and confirm if i am not mistaking and wrangler dev proxy does not implement caches API?

I am not very familiar with this codebase unfortunately, but by quickly skimming through the PR it all seems correct to me 🙂

Regarding the cache not being implemented you're right, we also have an issue for this: cloudflare/workers-sdk#4879 (which refers to getBidingsProxy the old name for getPlatformProxy, I'll update the issue with the correct name) unfortunately this piece of work has never been prioritized (also it being not trivial doesn't help). The fact that we're trying to get more and more code to run natively in our runtime also makes it a bit improbable in my opinion that we can prioritize getPlatformProxy-only features (unless there's a significant demand/motivation for it) 🥲

(PS: Running code inside miniflare should support the caching API... although I just manually checked that and that doesn't seem to work... I'll need to investigate a bit 🤔)

(PS: sorry for the late reply, I only now saw this 🙇)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloudflare Workers Cache API driver
5 participants