Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better source code documentation - Questions about how it works #18

Closed
Vadorequest opened this issue Dec 6, 2019 · 4 comments
Closed

Comments

@Vadorequest
Copy link

I've read https://zeit.co/blog/serverless-pre-rendering and I'm interested by SPR, but I don't fully understand how it works.

AFAIU, everything is done there https://github.com/zeit/spr-landing/blob/master/pages/index.js#L177-L180

  if (res) {
    res.setHeader("Cache-Control", "s-maxage=1, stale-while-revalidate");
    res.setHeader("X-version", etag);
  }

Few questions:

  • What's the goal of X-version here? What happens if I don't define it?
  • How does this cache implementation works? I don't understand how defining a 1s cache can change anything performance-wise.
  • Basically, considering I have a Next.js app which does SSR (fetching content from a headless CMS in _app:getInitialProps), what would happen if I just add those two lines in _app/getInitialProps?
@timneutkens
Copy link
Member

You can read more about it here: https://zeit.co/blog/serverless-pre-rendering

@Vadorequest
Copy link
Author

Yeah, I saw, this link is how I heard of this project (as I stated in my post), but I still don't understand the technicals at hand.

@Siilwyn
Copy link

Siilwyn commented Jan 10, 2020

Just dug into this, the cache control header just signals the CDN to cache the whole page as stated in the blog post. The X-version header & etag are not needed unless you want to refresh the page client-side when the displayed page is out of date.

@ijjk
Copy link
Member

ijjk commented Jan 11, 2020

Hey folks! We have upgraded this repo to take advantage of incremental static site generation (iSSG). In short:

  • There’s never a cold boot anymore when accessing the page
  • The page gets incrementally re-built asynchronously
  • Always fast & available

This is thanks to Next.js' new hooks for static site generation, see the RFC here, where you can learn more about how this works.

I’m closing this issue for now as it’s no longer applicable. Feel free to ping me with any questions.

@ijjk ijjk closed this as completed Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants