Use page specific stale-while-revalidate Cache-Control headers
This commit is contained in:
@@ -4,7 +4,7 @@ import { fetchAPI } from '$utils/api'
|
||||
import { getRandomItem } from '$utils/functions'
|
||||
import { fetchSwell } from '$utils/functions/shopServer'
|
||||
|
||||
export const load: PageServerLoad = async ({}) => {
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
try {
|
||||
// Get content from API
|
||||
const data = await fetchAPI(`query {
|
||||
@@ -42,6 +42,8 @@ export const load: PageServerLoad = async ({}) => {
|
||||
const shopProduct: any = await fetchSwell(`/products/${randomPoster.product_id}`)
|
||||
|
||||
if (shopProduct) {
|
||||
setHeaders({ 'Cache-Control': 'public, max-age=1, stale-while-revalidate=86399' })
|
||||
|
||||
return {
|
||||
product: randomPoster,
|
||||
shopProduct,
|
||||
|
||||
Reference in New Issue
Block a user