Skipping static generation for pages using getStaticProps
at build time
#32087
Replies: 4 comments 4 replies
-
Or maybe it'd be better to have a |
Beta Was this translation helpful? Give feedback.
-
So we've encountered a somewhat similar problem. Our setup currently builds a CMS docker image as the backend, and a Next frontend image as seperated Gitlab-Ci Jobs and pushes them to our Gitlab container registry. The CMS docker image (craftcms/nginx) nginx configuration file contains the proxy_pass configuration to forward all requests towards the frontend container. Both containers are then deployed via Portainer. By using proxy_pass in the backend container we can ensure that the frontend can only be reached when the backend CMS container is running. The problem arises in the building process of the frontend image using getStaticProps and revalidate. We think that by allowing getStaticProps at build time to be skipped, we would not have 30 seconds of "revalidate downtime". Secondly a problem arises when we already have an existing instance of frontend and backend containers deployed and we redeploy both a new frontend and backend container with differing data or queries by pushing new images to the registry. |
Beta Was this translation helpful? Give feedback.
-
How about using // This value is considered fresh for ten seconds (s-maxage=10).
// If a request is repeated within the next 10 seconds, the previously
// cached value will still be fresh. If the request is repeated before 59 seconds,
// the cached value will be stale but still render (stale-while-revalidate=59).
//
// In the background, a revalidation request will be made to populate the cache
// with a fresh value. If you refresh the page, you will see the new value.
export async function getServerSideProps({ req, res }) {
res.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)
return {
props: {},
}
} This would:
Am I, perhaps, missing something else? |
Beta Was this translation helpful? Give feedback.
-
Any updates? |
Beta Was this translation helpful? Give feedback.
-
Describe the feature you'd like to request
Could you please allow skipping static page generation at build time for pages using
getStaticProps
? Currently I have anindex.tsx
file for a page but I can't build it at CI because it doesn't have access to the data. Instead I would like to only build this page when there's an incoming request.getStaticProps
is great because it introduces an additional caching layer to the application but forcing developers to generate such pages at build time feels more like a limitation. Currently this is not possible and I see the following error during the build:Describe the solution you'd like
Additional config options is fine.
Describe alternatives you've considered
I can rename
index.tsx
to[index].tsx
and run a check if page path is/page-name
and return 404 if it's not. It's rather workaround than a solution.Beta Was this translation helpful? Give feedback.
All reactions