Define global allowQuery / varies in nitro config

Open
#5,000 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
40/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

The feature touches the cache configuration in nitro.config.ts and the cachedHandler options, so start with how cache.defaults is read and merged with per-handler allowQuery and varies. The docs at https://nitro.build/docs/cache#global-options are the reference for current behaviour. Done means a global default can be set and a handler's cache key includes it, with the merge rule documented.

Written by the indexing model from the issue text.

Description

cache config
Describe the feature

It would be nice if query params can be set in nitro.config.ts, so these query params always vary the cache key and reach every handler.

E.g. if every route takes a locale query param ?locale=fr, locale could be added globally so one does not have to add it to every cachedHandler (and possibly forgets it).

The same example when using Accept-Language header instead of query param: accept-language could be added to global varies, so one does not have to add it to every cachedHandler (and possibly forgets it).

Additional information

Apparently nitro config already allows for cache.defaults to be set but the docs don't say whether cachedHandlers allowQuery replaces or merges with the default: https://nitro.build/docs/cache#global-options

Dominant language
TypeScript
Stars
11.5k
Forks
968
Avg merge
4d 9h
Merged PRs (30d)
64

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nitrojs/nitro

All issues in nitrojs/nitro

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.