Skip to content

Commit

Permalink
docs: add note about cache options for route options
Browse files Browse the repository at this point in the history
Co-Authored-By: Louis Haftmann <30736553+LouisHaftmann@users.noreply.github.com>
  • Loading branch information
pi0 and LouisHaftmann committed Oct 15, 2022
1 parent 298cff6 commit 221c747
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/content/3.config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,20 @@ export default <NitroErrorHandler> function (error, event) {

**🧪 Experimental!**

Route options. It is a map from route pattern (following [unjs/radix3](https://github.com/unjs/radix3)) to options.
Route options. It is a map from route pattern (following [unjs/radix3](https://github.com/unjs/radix3#route-matcher)) to route options.

Example:
When `cache` option is set, handlers matching pattern will be automatically wrapped with `defineCachedEventHandler`. See [Cache API](/guide/introduction/cache) for all available cache options. (`swr: true|number` is shortcut for `cache: { swr: true, maxAge: number }`.)


**Example:**

```js
{
routes: {
'/blog/**': { swr: true },
'/blog/**': { swr: 600 },
'/blog/**': { static: true },
'/blog/**': { cache: { /* cache options*/ } },
'/assets/**': { headers: { 'cache-control': 's-maxage=0' } },
'/api/v1/**': { cors: true, headers: { 'access-control-allowed-methods': 'GET' } },
'/old-page': { redirect: '/new-page' }
Expand Down

0 comments on commit 221c747

Please sign in to comment.