Skip to content

Commit

Permalink
Revert "chore(perf): leverage ISR instead for query caching"
Browse files Browse the repository at this point in the history
This reverts commit dee73c6.
  • Loading branch information
atinux committed Dec 20, 2023
1 parent 6b94f13 commit 6a56986
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/runtime/server/api/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { createNav } from '../navigation'
import type { ParsedContent, ParsedContentMeta } from '../../types'
import { getContentQuery } from '../../utils/query'
import { isPreview } from '../preview'
import { eventHandler } from '#imports'
import { cachedEventHandler } from '#imports'

export default eventHandler(async (event) => {
export default cachedEventHandler(async (event) => {
const query = getContentQuery(event)

// Read from cache if not preview and there is no query
Expand Down Expand Up @@ -50,4 +50,7 @@ export default eventHandler(async (event) => {
}, {} as Record<string, ParsedContentMeta>)

return createNav((contents?.result || contents) as ParsedContentMeta[], configs)
}, {
maxAge: 31536000,
shouldBypassCache: () => !!import.meta.dev
})
7 changes: 5 additions & 2 deletions src/runtime/server/api/query.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createError } from 'h3'
import { serverQueryContent } from '../storage'
import { getContentQuery } from '../../utils/query'
import { useRuntimeConfig, eventHandler } from '#imports'
import { useRuntimeConfig, cachedEventHandler } from '#imports'

export default eventHandler(async (event) => {
export default cachedEventHandler(async (event) => {
const query = getContentQuery(event)
const { advanceQuery } = useRuntimeConfig().public.content.experimental

Expand Down Expand Up @@ -39,4 +39,7 @@ export default eventHandler(async (event) => {
}

return serverQueryContent(event, query).find()
}, {
maxAge: 31536000,
shouldBypassCache: () => !!import.meta.dev
})

0 comments on commit 6a56986

Please sign in to comment.