From ae3148337b9c520e562c51902fdb119fb0153283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Wed, 7 Oct 2020 13:36:17 +0200 Subject: [PATCH] Set Cache-Control headers for certain content on Firebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My reasoning is: * any CSS or JS files their name contains their hash — 1 month * anything under img folder might change while keeping name — 1 day * any image anywhere except img folder usually giant photos attached to blog posts, rarely change and if they do, they usually change name as well — 1 month --- firebase.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/firebase.json b/firebase.json index e782939..93aabb7 100644 --- a/firebase.json +++ b/firebase.json @@ -5,6 +5,35 @@ "firebase.json", "**/.*", "**/node_modules/**" + ], + "headers": [ + { + "source": "@(js|css)/*.@(js|css)", + "headers": [ + { + "key": "Cache-Control", + "value": "max-age=2628000" + } + ] + }, + { + "source": "img/**", + "headers": [ + { + "key": "Cache-Control", + "value": "max-age=86400" + } + ] + }, + { + "source": "!(img)/**/*.@(jpg|jpeg|png|webp)", + "headers": [ + { + "key": "Cache-Control", + "value": "max-age=2628000" + } + ] + } ] } }