Created
July 9, 2019 14:29
-
-
Save evdama/979b36c4f9772ea1a8cc1ad4fac62e1e to your computer and use it in GitHub Desktop.
index.ts with cache control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: replace type any for request and response | |
// Start writing Firebase Functions | |
// https://firebase.google.com/docs/functions/typescript | |
const functions = require('firebase-functions'); | |
// We have to import the built version of the server middleware. | |
const { app } = require('../__sapper__/build/server/server'); | |
const oneHour = 60 * 60 | |
const oneDay = oneHour * 24 | |
const oneWeek = oneDay * 7 | |
const oneMonth = oneWeek * 4 | |
app.get('/', (request: any, response: any) => { | |
response.set( | |
'Cache-Control', | |
`public, max-age=${oneWeek}, must-revalidate, s-maxage=${oneWeek}, proxy-revalidate, stale-while-revalidate=${oneDay}, stale-if-error=${oneWeek}` | |
); | |
response.send(app); | |
}) | |
exports.ssr = functions | |
.region('us-central1') | |
.https.onRequest(app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment