Different cacheing behaviour then the expected from getStaticProps function
See original GitHub issueWhich Package & Your Environment
- Package in this repo: https://github.com/jthegedus/firebase-gcp-examples/tree/master/functions-nextjs
- OS: macOS Catalina
- Node Version: 10
- Pkg Manager: yarn
- Shell: bash
- Browser & version: Chrome Version 81.0.*
- Language: Javascript
Expected Behaviour
I am expecting to have the same behavior in the browser as mentioned in code. immutable
https://github.com/jthegedus/firebase-gcp-examples/blob/master/functions-nextjs/pages/blog/[pid].js
Actual Behaviour
But, getting this header in response stale-while-revalidate
Due to which firebase CDN is not always caching this page. ([pid].js) and some times I am getting cache MISS.
initially (just after deployment) not even getting cache headers.
Possible Solution
Probably a correct response header through server.js file.
Context
I have a requirement where my app will have 40k pages and all of them gonna change on the next build. I want to cache all my pages at the CDN level until the next build.
I tried setting a response header in getServerSideProps
. it works fine for me. But, my question is can I achieve this with getStaticProps
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (11 by maintainers)
Did your Cloud Run deployment succeed? If so, make sure the region you deployed your Cloud Run service matches the region in your
firebase.json
.It might also just be that you need to upgrade to Blaze payment model for your Firebase project.
I have updates to that Cloud Run example I’ll be publishing tomorrow. Mainly around deployment
Edit: yep, probably just blaze payment plan as it’s required for cloud run - https://firebase.google.com/docs/hosting/cloud-run#enable-billing
Cloud Run does have a free tier almost identical to cloud functions
I do not have a complete understanding of this functionality, but I believe
__NEXT_DATA__
is the mechanism Next.js uses to hydrate the data for the page from the.json
which is different for each SSG page. I do not think this can be replaced. Perhaps you should ask this question in the Next.js repo as you will have better feedback about what you may be able to do to stop web scraping.