Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add cache base option example & description #781

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/content/1.guide/1.introduction/5.cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const cachedFn = cachedEventHandler(fn, options)
- `integrity`: A value that changing it, will invalidate all caches for function. By default will be computed from **function code**.
- `maxAge`: Maximum age that cache is valid in seconds. Default is `1` second.
- `swr`: Enable Stale-While-Revalidate behavior. Enabled by default.
- `base`: Name of the storage mointpoint to use for caching (`/cache` by default)


## Examples
Expand Down Expand Up @@ -54,3 +55,28 @@ export default defineNitroConfig({
}
})
```


**Example:** Set cache storage mountpoint for a group of routes (**πŸ§ͺ Experimental!**)

```js
// nitro.config.ts
import { defineNitroConfig } from 'nitropack'

export default defineNitroConfig({
storage: {
'my-custom-storage': {
driver: 'redis',
url: 'redis://localhost:6379'
}
},
routeRules: {
'/blog/**': {
swr: true,
cache: {
base: '/my-custom-storage'
}
}
}
})
```