RFC: Response cache
The author should do the following, if applicable
- [ ] Add tests
- [ ] Run tests
- [ ]
yarn changesetat the top of this repo and push the changeset - [ ] Follow the contribution guide
⚠️ No Changeset found
Latest commit: b8b1987f2f56732f31ac413fd78ca78f7ef772a0
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
@yusukebe Hy, could you check this out please? :) Still very basic, no tests even yet, just to get feeling/idea if there would be interest to continue with this
At first glance, I don't think this is needed. We already have the built-in Cache Middleware. If you want to cache just "Response", it's enough to use it.
As per my understanding, that middleware only works on cloudflare an deno, and uses specific cache mechanism. This allows little bit more freedom, for example, by using redis which has TTL (unlike Cache API).
Also, correct me if I'm wrong, but that Cache API helps cache'ing it on Cloudflare/DenoDeploy level, basically "edge/cdn" rather than on server, right?
Forgot to mention - this allows to customize cache’ing keys. So for example, if you’re running A/B test, and store A/B tests list in cookie - you can use that cookie to allow to cache page rendered under specific A/B conditions.
Quite niche example, but solution is quite lightweight with provided flexibility.
@muningis
Thank you for the explanation! Makes sense.
Also, correct me if I'm wrong, but that Cache API helps cache'ing it on Cloudflare/DenoDeploy level, basically "edge/cdn" rather than on server, right?
Yes. The Cache API is standardized, but you can only use it in particular runtimes like Cloudflare Workers and Deno.
This middleware looks good. Let's go ahead.