Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Response cache #985

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

RFC: Response cache #985

wants to merge 1 commit into from

Conversation

muningis
Copy link
Contributor

The author should do the following, if applicable

  • Add tests
  • Run tests
  • yarn changeset at the top of this repo and push the changeset
  • Follow the contribution guide

Copy link

changeset-bot bot commented Feb 27, 2025

⚠️ No Changeset found

Latest commit: b8b1987

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

@muningis muningis force-pushed the response-cache branch 4 times, most recently from 7f31f1a to c42ca1c Compare February 27, 2025 18:16
@muningis
Copy link
Contributor Author

muningis commented Mar 4, 2025

@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

@yusukebe
Copy link
Member

yusukebe commented Mar 4, 2025

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.

@muningis
Copy link
Contributor Author

muningis commented Mar 5, 2025

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?

@muningis
Copy link
Contributor Author

muningis commented Mar 6, 2025

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.

@yusukebe
Copy link
Member

yusukebe commented Mar 7, 2025

@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.

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.

2 participants