Skip to content

Commit

Permalink
Firebase CDN caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Chetan Padia committed Oct 10, 2024
1 parent 820af23 commit a9b755c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export const imagePng = functions.https.onRequest(async (request, response) => {
}
}
const packedImage = image.pack();
packedImage.pipe(response).type("image/png");
packedImage
.pipe(response)
.set("Cache-Control", "public, max-age=86400, s-maxage=86400")
.type("image/png");
} catch (error) {
response.status(500).send(error);
}
Expand All @@ -84,7 +87,10 @@ export const historyGif = functions
maxFrameDelay: 500,
scale: 1,
});
response.type("image/gif").end(Buffer.from(imageData), "binary");
response
.set("Cache-Control", "public, max-age=86400, s-maxage=604800")
.type("image/gif")
.end(Buffer.from(imageData), "binary");
} catch (error) {
response.status(500).send(error);
}
Expand Down

0 comments on commit a9b755c

Please sign in to comment.