Use page specific stale-while-revalidate Cache-Control headers
This commit is contained in:
@@ -3,7 +3,7 @@ import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { getRandomItems } from '$utils/functions'
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
try {
|
||||
// Get total of published photos
|
||||
const totalRes = await fetchAPI(`query {
|
||||
@@ -43,6 +43,8 @@ export const load: PageServerLoad = async () => {
|
||||
const { data: { photo: photos }} = photosRes
|
||||
|
||||
if (photos) {
|
||||
setHeaders({ 'Cache-Control': 'public, max-age=1, stale-while-revalidate=599' })
|
||||
|
||||
return {
|
||||
photos,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user