Add Cache-Control max-age headers globally

This commit is contained in:
2022-09-19 23:38:07 +02:00
parent e0b28551b8
commit 3a7056cce6
3 changed files with 8 additions and 6 deletions

View File

@@ -29,7 +29,7 @@
"@sveltejs/adapter-auto": "^1.0.0-next.76", "@sveltejs/adapter-auto": "^1.0.0-next.76",
"@sveltejs/adapter-node": "^1.0.0-next.92", "@sveltejs/adapter-node": "^1.0.0-next.92",
"@sveltejs/adapter-vercel": "^1.0.0-next.76", "@sveltejs/adapter-vercel": "^1.0.0-next.76",
"@sveltejs/kit": "^1.0.0-next.487", "@sveltejs/kit": "^1.0.0-next.488",
"@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0", "@typescript-eslint/parser": "^5.38.0",
"base-64": "^1.0.0", "base-64": "^1.0.0",

8
pnpm-lock.yaml generated
View File

@@ -5,7 +5,7 @@ specifiers:
'@sveltejs/adapter-auto': ^1.0.0-next.76 '@sveltejs/adapter-auto': ^1.0.0-next.76
'@sveltejs/adapter-node': ^1.0.0-next.92 '@sveltejs/adapter-node': ^1.0.0-next.92
'@sveltejs/adapter-vercel': ^1.0.0-next.76 '@sveltejs/adapter-vercel': ^1.0.0-next.76
'@sveltejs/kit': ^1.0.0-next.487 '@sveltejs/kit': ^1.0.0-next.488
'@typescript-eslint/eslint-plugin': ^5.38.0 '@typescript-eslint/eslint-plugin': ^5.38.0
'@typescript-eslint/parser': ^5.38.0 '@typescript-eslint/parser': ^5.38.0
base-64: ^1.0.0 base-64: ^1.0.0
@@ -49,7 +49,7 @@ devDependencies:
'@sveltejs/adapter-auto': 1.0.0-next.76 '@sveltejs/adapter-auto': 1.0.0-next.76
'@sveltejs/adapter-node': 1.0.0-next.92 '@sveltejs/adapter-node': 1.0.0-next.92
'@sveltejs/adapter-vercel': 1.0.0-next.76 '@sveltejs/adapter-vercel': 1.0.0-next.76
'@sveltejs/kit': 1.0.0-next.487_svelte@3.50.1+vite@3.1.3 '@sveltejs/kit': 1.0.0-next.488_svelte@3.50.1+vite@3.1.3
'@typescript-eslint/eslint-plugin': 5.38.0_wsb62dxj2oqwgas4kadjymcmry '@typescript-eslint/eslint-plugin': 5.38.0_wsb62dxj2oqwgas4kadjymcmry
'@typescript-eslint/parser': 5.38.0_irgkl5vooow2ydyo6aokmferha '@typescript-eslint/parser': 5.38.0_irgkl5vooow2ydyo6aokmferha
base-64: 1.0.0 base-64: 1.0.0
@@ -478,8 +478,8 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@sveltejs/kit/1.0.0-next.487_svelte@3.50.1+vite@3.1.3: /@sveltejs/kit/1.0.0-next.488_svelte@3.50.1+vite@3.1.3:
resolution: {integrity: sha512-DLrjiwrD0D2dUUL3ld4TFXhqdOHzhBW2C0vje70kuPZrbqq0sHZM2k+hYvgOf+r277N9AGfglve7RR4Ze08fDg==} resolution: {integrity: sha512-CUeIFxo90FDItZaW+o47ZQaWKTdu9EN4oJKTf7IQZFT/Ch8QlxRxF2clg0XIOB5hJjakQeJplK4YOJtyVZ31jw==}
engines: {node: '>=16.14'} engines: {node: '>=16.14'}
hasBin: true hasBin: true
requiresBuild: true requiresBuild: true

View File

@@ -4,7 +4,7 @@ import { fetchAPI } from '$utils/api'
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public' import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
export const load: PageServerLoad = async () => { export const load: PageServerLoad = async ({ setHeaders }) => {
try { try {
const res = await fetchAPI(`query { const res = await fetchAPI(`query {
locations: location (filter: { status: { _eq: "published" }}) { locations: location (filter: { status: { _eq: "published" }}) {
@@ -87,6 +87,8 @@ export const load: PageServerLoad = async () => {
}`) }`)
if (res) { if (res) {
setHeaders({ 'Cache-Control': 'public, max-age=3600' })
const { data: { countPhotos, countLocations, countCountries, ...rest }} = res const { data: { countPhotos, countLocations, countCountries, ...rest }} = res
return { return {