Skip to content

Commit 5cf5dad

Browse files
Merge branch 'main' into mk/no-beta
2 parents ddbc40a + f313dbb commit 5cf5dad

File tree

9 files changed

+1266
-1116
lines changed

9 files changed

+1266
-1116
lines changed

demos/default/netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
command = "next build"
33
publish = ".next"
4-
ignore = "echo CACHED_COMMIT_REF: $CACHED_COMMIT_REF COMMIT_REF: $COMMIT_REF && git diff --exit-code $CACHED_COMMIT_REF $COMMIT_REF ../../"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
55

66
[build.environment]
77
# cache Cypress binary in local "node_modules" folder

demos/nx-next-monorepo-demo/netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
command = "npm run build"
33
publish = "dist/apps/demo-monorepo/.next"
4-
ignore = "git diff --exit-code $CACHED_COMMIT_REF $COMMIT_REF ../../"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
55

66
[dev]
77
command = "npm run start"

demos/nx-next-monorepo-demo/package-lock.json

+674-604
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/nx-next-monorepo-demo/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"@types/node": "16.11.12",
3535
"@types/react": "17.0.37",
3636
"@types/react-dom": "17.0.11",
37-
"@typescript-eslint/eslint-plugin": "~4.33.0",
38-
"@typescript-eslint/parser": "~4.33.0",
39-
"babel-jest": "27.4.2",
37+
"@typescript-eslint/eslint-plugin": "~5.6.0",
38+
"@typescript-eslint/parser": "~5.6.0",
39+
"babel-jest": "27.4.4",
4040
"cypress": "^8.3.0",
4141
"eslint": "8.4.1",
4242
"eslint-config-next": "12.0.7",
@@ -46,7 +46,7 @@
4646
"eslint-plugin-jsx-a11y": "6.5.1",
4747
"eslint-plugin-react": "7.26.1",
4848
"eslint-plugin-react-hooks": "4.3.0",
49-
"jest": "27.4.3",
49+
"jest": "27.4.4",
5050
"prettier": "^2.3.1",
5151
"ts-jest": "27.1.1",
5252
"typescript": "~4.5.0",

demos/static-root/netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
command = "next build"
33
publish = ".next"
4-
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
55

66
[build.environment]
77
# cache Cypress binary in local "node_modules" folder

docs/isr.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Incremental Static Regeneration (ISR)
2+
3+
[Incremental static regeneration](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration) is a feature
4+
of Next.js that allows pages to be updated after a site has been built and deployed. It is now fully supported in
5+
Netlify by the Essential Next.js plugin, meaning large sites can update pages without needing to rebuild the entire
6+
site. Unlike server-side rendered pages, the page is not rebuilt for each user, so they load quickly, but unlike
7+
statically-generated pages they can be periodically updated with new content without a new deploy.
8+
9+
### Using ISR on Netlify
10+
11+
ISR on Netlify is implemented with [On Demand Builders](https://docs.netlify.com/configure-builds/on-demand-builders/),
12+
using the TTL feature. You can enable ISR for a page by returning a value for `revalidate` from the `getStaticProps`
13+
function. This value is the number of seconds for which the content will be considered fresh. If a request arrives for a
14+
page after the `revalidate` period has elapsed, the page will be regenerated. ISR uses a "stale while revalidate"
15+
strategy, meaning that the visitor still receives the stale content, but it is regenerated in the background ready for
16+
the next request. The generated page is persisted globally, so is available to all visitors wherever they are in the
17+
world. It is also cached in the global Netlify CDN so responses are fast.
18+
19+
The minimum value for `revalidate` is 60 seconds, and any value less than that will be rounded-up to 60 seconds. After a
20+
request is made for stale content, the page will be regenerated in the background and immediately persisted globally,
21+
but it can take up to 60 seconds before the new content is then updated in all CDN nodes if they already had a cached
22+
copy.
23+
24+
If a new deploy is made, all persisted pages and CDN cached pages will be invalidated so that conflicts are avoided. If
25+
this did not happen, a stale HTML page might make a request for an asset that no longer exists in the new deploy. By
26+
invalidating all persisted pages, you can be confident that this will never happen and that deploys remain atomic.
27+
28+
### Alternatives to ISR
29+
30+
ISR is best for situations where there are regular updates to content throughout the day, particularly you don't have
31+
control over when it happens. It is less ideal in situations such as a CMS with incremental updates where you can have
32+
the CMS trigger a deploy when a page is added or edited. This offers the best performance and avoids unnecesary
33+
rebuilds.
34+
35+
### Static site generation
36+
37+
For high-traffic pages you can use
38+
[static generation](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation) without
39+
`revalidate`, which deploys static files directly to the CDN for maximum performance.
40+
41+
### Distributed persistent rendering
42+
43+
For less commonly-accessed content you can use return `fallback: "blocking"` from
44+
[`getStaticPaths`](https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation) and defer
45+
builds until the first request. This also uses On Demand Builders, but persists the built page until the next deploy.
46+
This is great for long-tail content and archives that don't change often but are not accessed often enough to justify
47+
statically-generating them at build time.

0 commit comments

Comments
 (0)