Skip to content

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

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2025

🦋 Changeset detected

Latest commit: cc46026

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/response-cache Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@muningis muningis force-pushed the response-cache branch 5 times, most recently from c42ca1c to b8b1987 Compare February 27, 2025 18:19
@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.

@piotrcichosz
Copy link

redis - or for example Cloudflare KV..

@muningis are you planning on finishing this PR?

@muningis
Copy link
Contributor Author

Had completely forgoten about this. I will get back to this next week.

…der filtering

- Store full response (body, status, headers) instead of just body text
- Filter sensitive headers (Set-Cookie, WWW-Authenticate, etc.)
- Remove `respond` as it's inferred from `Content-Type` header
- Add vitest tests
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.46%. Comparing base (d14f1de) to head (cc46026).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #985      +/-   ##
==========================================
+ Coverage   84.35%   84.46%   +0.11%     
==========================================
  Files         119      120       +1     
  Lines        3879     3907      +28     
  Branches     1047     1054       +7     
==========================================
+ Hits         3272     3300      +28     
  Misses        516      516              
  Partials       91       91              
Flag Coverage Δ
response-cache 0.71% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@yusukebe
Copy link
Member

yusukebe commented Dec 7, 2025

@muningis

If this is ready to review, please ping me.

@muningis
Copy link
Contributor Author

muningis commented Dec 7, 2025

Hello @yusukebe, yes this is ready now.

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.

3 participants