Skip to content

fix(cache): preserve web response bodies and headers - #51

Open
lafllamme wants to merge 1 commit into
nitrojs:mainfrom
lafllamme:fix/cache-web-response
Open

lafllamme wants to merge 1 commit into
nitrojs:mainfrom
lafllamme:fix/cache-web-response

Conversation

@lafllamme

@lafllamme lafllamme commented Nov 24, 2026 •

Copy link
Copy Markdown

🔗 Linked issue

Related to nuxt/image#2392 and nitrojs/nitro#1894.

❓ Type of change

  • 🐞 Bug fix

📚 Description

Cached handlers that return a Web Response lose the response body and headers when Nitro serializes the cache entry. For example, an IPX image can be returned as {} on a cache hit.

This stores Web response bodies as base64 and restores them on cache hits, while preserving their status and headers. It follows the binary response support shipped in Nitro v3's ocache (unjs/ocache#66, released in ocache 0.2.0 and included in Nitro 3.0.261103-rc's dependency range). Responses are buffered when cached.

Added a regression test for the status, headers and binary bytes on the initial response and cache hit. Also checked a Nuxt Image app with Nitro 2.14.0: two IPX requests returned identical PNG bytes and content types.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Validation: pnpm test (976 passed, 196 skipped), pnpm test:types.

@lafllamme
lafllamme requested a review from pi0 as a code owner November 24, 2026 12:09
@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@lafllamme is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2e95074-d3df-4fdf-a606-3469b86ccdf1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

1 participant