From 130735a651cba4cc27a1c11c5af2c6ebc333f322 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 9 Aug 2022 16:30:34 -0700 Subject: [PATCH] Set cache headers on newly uploaded avatars --- web/lib/firebase/storage.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/lib/firebase/storage.ts b/web/lib/firebase/storage.ts index fcf4422d..3acfbae9 100644 --- a/web/lib/firebase/storage.ts +++ b/web/lib/firebase/storage.ts @@ -3,6 +3,8 @@ import imageCompression from 'browser-image-compression' import { nanoid } from 'nanoid' import { storage } from './init' +const ONE_YEAR_SECS = 60 * 60 * 24 * 365 + export const uploadImage = async ( username: string, file: File, @@ -24,7 +26,9 @@ export const uploadImage = async ( }) } - const uploadTask = uploadBytesResumable(storageRef, file) + const uploadTask = uploadBytesResumable(storageRef, file, { + cacheControl: `public, max-age=${ONE_YEAR_SECS}`, + }) let resolvePromise: (url: string) => void let rejectPromise: (reason?: any) => void