Skip to content

Commit d4e1ae9

Browse files
serhalp43081jcoderabbitai[bot]danielroe
authored
docs: add contributing section about cache busting in dev (#1617)
Co-authored-by: James Garbutt <43081j@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent 4b98444 commit d4e1ae9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This focus helps guide our project decisions as a community and what we choose t
3131
- [Setup](#setup)
3232
- [Development workflow](#development-workflow)
3333
- [Available commands](#available-commands)
34+
- [Clearing caches during development](#clearing-caches-during-development)
3435
- [Project structure](#project-structure)
3536
- [Local connector CLI](#local-connector-cli)
3637
- [Mock connector (for local development)](#mock-connector-for-local-development)
@@ -124,6 +125,34 @@ pnpm test:a11y # Lighthouse accessibility audits
124125
pnpm test:perf # Lighthouse performance audits (CLS)
125126
```
126127

128+
### Clearing caches during development
129+
130+
Nitro persists `defineCachedEventHandler` results to disk at `.nuxt/cache/nitro/`. This cache **survives dev server restarts**. If you're iterating on a cached API route and want fresh results, delete the relevant cache directory:
131+
132+
```bash
133+
# Clear all Nitro handler caches
134+
rm -rf .nuxt/cache/nitro/handlers/
135+
136+
# Clear a specific handler cache (e.g. picks)
137+
rm -rf .nuxt/cache/nitro/handlers/npmx-picks/
138+
```
139+
140+
Alternatively, you can bypass the cache entirely in development by adding `shouldBypassCache: () => import.meta.dev` to your `defineCachedEventHandler` options:
141+
142+
```ts
143+
export default defineCachedEventHandler(
144+
async event => {
145+
// ...
146+
},
147+
{
148+
maxAge: 60 * 5,
149+
shouldBypassCache: () => import.meta.dev,
150+
},
151+
)
152+
```
153+
154+
The `.cache/` directory is a separate storage mount used for fetch-cache and atproto data.
155+
127156
### Project structure
128157

129158
```

0 commit comments

Comments
 (0)