Skip to content

feat(cache): add allowQuery option to filter query params in cache key#4079

Open
fmoessle wants to merge 3 commits intonitrojs:v2from
fmoessle:feat/cache-allow-query-v2
Open

feat(cache): add allowQuery option to filter query params in cache key#4079
fmoessle wants to merge 3 commits intonitrojs:v2from
fmoessle:feat/cache-allow-query-v2

Conversation

@fmoessle
Copy link
Contributor

@fmoessle fmoessle commented Mar 6, 2026

Summary

  • Adds allowQuery option to defineCachedEventHandler and route rules cache config
  • When set, only the listed query parameter names are included in the cache key
  • If set to an empty array [], all query parameters are ignored (only pathname is used)
  • If undefined (default), all query parameters are included — no behavior change
  • Useful for ignoring tracking params like utm_source, fbclid, etc.

Closes nuxt/nuxt#33728

Test plan

  • Added test fixture api/cached-allow-query.ts with allowQuery: ["q"]
  • Added route rule /rules/allow-query/** with allowQuery: ["q"]
  • Added test: same q param with different unlisted params hits cache
  • Added test: different q param gets different cache entry
  • Tests pass on multiple presets (node, cloudflare-pages, cloudflare-module, etc.)
  • Updated cache docs with allowQuery field

🤖 Generated with Claude Code

Allow users to specify which query parameters should be included in the cache key
via `allowQuery` option on `defineCachedEventHandler` and route rules cache config.

- `undefined`: all query params included (default, no behavior change)
- `[]`: all query params ignored (only pathname used)
- `["q"]`: only listed params included

Closes nuxt/nuxt#33728

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fmoessle fmoessle requested a review from pi0 as a code owner March 6, 2026 18:46
@vercel
Copy link

vercel bot commented Mar 6, 2026

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aac820da-036f-4e52-87e3-482eaa2a3d4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

fmoessle and others added 2 commits March 6, 2026 19:49
Route rules config passes `allowQuery` as `readonly string[]`, so the
type needs to accept both mutable and readonly arrays (matching `varies`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitropack@4079

commit: f176e64

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