Skip to content

Commit baae710

Browse files
committed
bring back function caching, but vary by query=payload
1 parent 7eae74c commit baae710

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

app/routes/_libraries/blog.$.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ const fetchBlogPost = createServerFn({ method: 'GET' })
3030
const frontMatter = extractFrontMatter(file)
3131
const description = removeMarkdown(frontMatter.excerpt ?? '')
3232

33-
// setHeaders({
34-
// 'cache-control': 'public, max-age=0, must-revalidate',
35-
// 'cdn-cache-control': 'max-age=300, stale-while-revalidate=300, durable',
36-
// })
33+
setHeaders({
34+
'cache-control': 'public, max-age=0, must-revalidate',
35+
'cdn-cache-control': 'max-age=300, stale-while-revalidate=300, durable',
36+
'Netlify-Vary': 'query=payload',
37+
})
3738

3839
return {
3940
title: frontMatter.data.title,

app/routes/_libraries/blog.index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ const fetchFrontMatters = createServerFn({ method: 'GET' }).handler(
3030

3131
const frontMatter = extractFrontMatter(file)
3232

33-
// setHeaders({
34-
// 'cache-control': 'public, max-age=0, must-revalidate',
35-
// 'cdn-cache-control':
36-
// 'max-age=300, stale-while-revalidate=300, durable',
37-
// })
33+
setHeaders({
34+
'cache-control': 'public, max-age=0, must-revalidate',
35+
'cdn-cache-control':
36+
'max-age=300, stale-while-revalidate=300, durable',
37+
'Netlify-Vary': 'query=payload',
38+
})
3839

3940
return [
4041
info.id,

app/utils/config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ export const getTanstackDocsConfig = createServerFn({ method: 'GET' })
7474
throw new Error('Zod validation failed')
7575
}
7676

77-
// setHeaders({
78-
// 'cache-control': 'public, max-age=0, must-revalidate',
79-
// 'cdn-cache-control': 'max-age=300, stale-while-revalidate=300, durable',
80-
// })
77+
setHeaders({
78+
'cache-control': 'public, max-age=0, must-revalidate',
79+
'cdn-cache-control': 'max-age=300, stale-while-revalidate=300, durable',
80+
'Netlify-Vary': 'query=payload',
81+
})
8182

8283
return validationResult.data
8384
} catch (e) {

0 commit comments

Comments
 (0)