Use page specific stale-while-revalidate Cache-Control headers

This commit is contained in:
2022-09-20 00:20:18 +02:00
parent 39fc74d8e9
commit 5545871c85
12 changed files with 57 additions and 29 deletions

View File

@@ -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,