From 386211b24b730ce64689dd6e277732d039920c32 Mon Sep 17 00:00:00 2001 From: webfussel Date: Sun, 2 Feb 2025 00:44:49 +0100 Subject: [PATCH] FIX: firebase cache Better caching policies --- firebase.json | 19 +++++++++++++++++++ utils/image.ts | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/firebase.json b/firebase.json index ddb687d..4c9bf7f 100644 --- a/firebase.json +++ b/firebase.json @@ -1,5 +1,24 @@ { "hosting": { + "headers": [{ + "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)", + "headers" : [ { + "key" : "Access-Control-Allow-Origin", + "value" : "*" + } ] + }, { + "source" : "**/*.@(js|css)", + "headers" : [ { + "key" : "Cache-Control", + "value" : "max-age=604800" + } ] + }, { + "source" : "**/*.@(jpg|jpeg|gif|png|svg)", + "headers" : [ { + "key" : "Cache-Control", + "value" : "max-age=604800" + } ] + }], "public": ".output/public", "ignore": [ "firebase.json", diff --git a/utils/image.ts b/utils/image.ts index 02b64db..0e13a81 100644 --- a/utils/image.ts +++ b/utils/image.ts @@ -1 +1,3 @@ -export const getImage = (path : string, img : string) => (size : '1x' | '2x' | '3x', set : boolean) => `${path}${img}@${size}.webp${set ? ` ${size}` : ''}` \ No newline at end of file +export const getImage = + (path: string, img: string) => (size: "1x" | "2x" | "3x", set: boolean) => + `${path}${img}@${size}.webp${set ? ` ${size}` : ""}`;