From b67d461cd1a7f5472c4beedfcd1a821a944c64e7 Mon Sep 17 00:00:00 2001 From: Casper Date: Wed, 21 Sep 2022 13:43:42 +0800 Subject: [PATCH] perf: reduce Vercel serveless function usage (#106) Increase s-maxage for CDN caching and max-age for client-side caching, also add stale-while-revalidate that allow us to serve content from the Edge cache. --- vercel.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vercel.json b/vercel.json index c1694ecf0..9554673dd 100644 --- a/vercel.json +++ b/vercel.json @@ -2,22 +2,22 @@ "github": { "silent": true }, - "rewrites": [{ "source": "/api/(.*)", "destination": "/api" }], + "rewrites": [{"source": "/api/(.*)", "destination": "/api"}], "headers": [ { "source": "/api/cards/(.*)", "headers": [ { "key": "cache-control", - "value": "public, max-age=0, s-maxage=14400" + "value": "public, max-age=21600, s-maxage=21600, stale-while-revalidate=14400" } ] }, { "source": "/api/theme", "headers": [ - { "key": "Access-Control-Allow-Credentials", "value": "true" }, - { "key": "Access-Control-Allow-Origin", "value": "*" }, + {"key": "Access-Control-Allow-Credentials", "value": "true"}, + {"key": "Access-Control-Allow-Origin", "value": "*"}, { "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" @@ -34,6 +34,6 @@ "source": "/", "destination": "/demo" }, - { "source": "/demo", "destination": "/demo.html" } + {"source": "/demo", "destination": "/demo.html"} ] }