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

Add experimental clientSegmentCache flag #72626

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

acdlite
Copy link
Contributor

@acdlite acdlite commented Nov 12, 2024

This will be used to gate a rewrite of the client cache that we've just started. Eventually it should merge with the PPR rollout, but that's already in active experimentation and we don't want to harm the PPR rollout. This will also let us incrementally get to parity with the existing implementation, instead of trying to reach parity in one big step.

When enabled (and when a route is using PPR), prefetches will use a new per-segment cache instead of the existing per-page cache.

@acdlite acdlite requested a review from ztanner November 12, 2024 17:14
@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. type: next labels Nov 12, 2024
@ijjk
Copy link
Member

ijjk commented Nov 12, 2024

Stats from current PR

Default Build
General Overall increase ⚠️
vercel/next.js canary acdlite/next.js segment-cache-flag Change
buildDuration 19.1s 17.4s N/A
buildDurationCached 16.4s 14.4s N/A
nodeModulesSize 402 MB 402 MB ⚠️ +2.42 kB
nextStartRea..uration (ms) 468ms 480ms N/A
Client Bundles (main, webpack)
vercel/next.js canary acdlite/next.js segment-cache-flag Change
3323-HASH.js gzip 45.6 kB 45.6 kB N/A
43344b9e-HASH.js gzip 52.5 kB 52.5 kB N/A
441-HASH.js gzip 5.26 kB 5.26 kB N/A
6624.HASH.js gzip 169 B 169 B
framework-HASH.js gzip 57.3 kB 57.3 kB N/A
main-app-HASH.js gzip 232 B 233 B N/A
main-HASH.js gzip 33.2 kB 33.2 kB
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 33.3 kB 33.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary acdlite/next.js segment-cache-flag Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary acdlite/next.js segment-cache-flag Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 512 B 512 B
css-HASH.js gzip 339 B 342 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB N/A
edge-ssr-HASH.js gzip 265 B 265 B
head-HASH.js gzip 364 B 365 B N/A
hooks-HASH.js gzip 393 B 393 B
image-HASH.js gzip 4.41 kB 4.41 kB N/A
index-HASH.js gzip 268 B 269 B N/A
link-HASH.js gzip 2.78 kB 2.78 kB N/A
routerDirect..HASH.js gzip 328 B 326 B N/A
script-HASH.js gzip 397 B 395 B N/A
withRouter-HASH.js gzip 325 B 323 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.66 kB 1.66 kB
Client Build Manifests
vercel/next.js canary acdlite/next.js segment-cache-flag Change
_buildManifest.js gzip 749 B 749 B
Overall change 749 B 749 B
Rendered Page Sizes
vercel/next.js canary acdlite/next.js segment-cache-flag Change
index.html gzip 522 B 522 B
link.html gzip 537 B 540 B N/A
withRouter.html gzip 519 B 518 B N/A
Overall change 522 B 522 B
Edge SSR bundle Size
vercel/next.js canary acdlite/next.js segment-cache-flag Change
edge-ssr.js gzip 128 kB 128 kB N/A
page.js gzip 198 kB 198 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary acdlite/next.js segment-cache-flag Change
middleware-b..fest.js gzip 668 B 670 B N/A
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 31 kB 31 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 1 kB 1 kB
Next Runtimes
vercel/next.js canary acdlite/next.js segment-cache-flag Change
196-experime...dev.js gzip 322 B 322 B
196.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 319 kB 319 kB
app-page-exp..prod.js gzip 123 kB 123 kB
app-page-tur..prod.js gzip 136 kB 136 kB
app-page-tur..prod.js gzip 131 kB 131 kB
app-page.run...dev.js gzip 309 kB 309 kB
app-page.run..prod.js gzip 119 kB 119 kB
app-route-ex...dev.js gzip 36 kB 36 kB
app-route-ex..prod.js gzip 24.4 kB 24.4 kB
app-route-tu..prod.js gzip 24.4 kB 24.4 kB
app-route-tu..prod.js gzip 24.2 kB 24.2 kB
app-route.ru...dev.js gzip 37.6 kB 37.6 kB
app-route.ru..prod.js gzip 24.2 kB 24.2 kB
pages-api-tu..prod.js gzip 9.59 kB 9.59 kB
pages-api.ru...dev.js gzip 11.4 kB 11.4 kB
pages-api.ru..prod.js gzip 9.58 kB 9.58 kB
pages-turbo...prod.js gzip 20.9 kB 20.9 kB
pages.runtim...dev.js gzip 26.5 kB 26.5 kB
pages.runtim..prod.js gzip 20.9 kB 20.9 kB
server.runti..prod.js gzip 916 kB 916 kB
Overall change 2.32 MB 2.32 MB
build cache
vercel/next.js canary acdlite/next.js segment-cache-flag Change
0.pack gzip 2.01 MB 2.01 MB N/A
index.pack gzip 146 kB 145 kB N/A
Overall change 0 B 0 B
Diff details
Diff for page.js

Diff too large to display

Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for dynamic-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [2291],
   {
-    /***/ 8725: /***/ (
+    /***/ 4162: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/dynamic",
         function () {
-          return __webpack_require__(2589);
+          return __webpack_require__(6810);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 2081: /***/ (module, exports, __webpack_require__) => {
+    /***/ 9181: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -51,7 +51,7 @@
         __webpack_require__(3017)
       );
       const _loadablesharedruntime = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6846)
+        __webpack_require__(9922)
       );
       const isServerSide = "object" === "undefined";
       // Normalize loader to return the module as form { default: Component } for `React.lazy`.
@@ -152,11 +152,7 @@
       /***/
     },
 
-    /***/ 880: /***/ (
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) => {
+    /***/ 84: /***/ (__unused_webpack_module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -179,7 +175,7 @@
       /***/
     },
 
-    /***/ 6846: /***/ (
+    /***/ 9922: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -221,7 +217,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       const _react = /*#__PURE__*/ _interop_require_default._(
         __webpack_require__(3017)
       );
-      const _loadablecontextsharedruntime = __webpack_require__(880);
+      const _loadablecontextsharedruntime = __webpack_require__(84);
       function resolve(obj) {
         return obj && obj.default ? obj.default : obj;
       }
@@ -456,7 +452,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       /***/
     },
 
-    /***/ 2589: /***/ (
+    /***/ 6810: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -471,7 +467,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
         __webpack_require__(9901);
       /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(4032);
+        __webpack_require__(8187);
       /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1___default =
         /*#__PURE__*/ __webpack_require__.n(
           next_dynamic__WEBPACK_IMPORTED_MODULE_1__
@@ -480,12 +476,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       const DynamicHello = next_dynamic__WEBPACK_IMPORTED_MODULE_1___default()(
         () =>
           __webpack_require__
-            .e(/* import() */ 6624)
-            .then(__webpack_require__.bind(__webpack_require__, 6624))
+            .e(/* import() */ 9173)
+            .then(__webpack_require__.bind(__webpack_require__, 9173))
             .then((mod) => mod.Hello),
         {
           loadableGenerated: {
-            webpack: () => [/*require.resolve*/ 6624],
+            webpack: () => [/*require.resolve*/ 9173],
           },
         }
       );
@@ -512,12 +508,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       /***/
     },
 
-    /***/ 4032: /***/ (
+    /***/ 8187: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(2081);
+      module.exports = __webpack_require__(9181);
 
       /***/
     },
@@ -527,7 +523,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(8725)
+      __webpack_exec__(4162)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for image-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [2983],
   {
-    /***/ 8493: /***/ (
+    /***/ 5118: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(9071);
+          return __webpack_require__(865);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 3317: /***/ (module, exports, __webpack_require__) => {
+    /***/ 2465: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,17 +40,17 @@
         __webpack_require__(5993)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(3568)
+        __webpack_require__(2124)
       );
-      const _getimgprops = __webpack_require__(4193);
-      const _imageconfig = __webpack_require__(5388);
-      const _imageconfigcontextsharedruntime = __webpack_require__(7862);
-      const _warnonce = __webpack_require__(8332);
-      const _routercontextsharedruntime = __webpack_require__(7151);
+      const _getimgprops = __webpack_require__(3525);
+      const _imageconfig = __webpack_require__(7256);
+      const _imageconfigcontextsharedruntime = __webpack_require__(9122);
+      const _warnonce = __webpack_require__(6976);
+      const _routercontextsharedruntime = __webpack_require__(4955);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(3997)
+        __webpack_require__(617)
       );
-      const _usemergedref = __webpack_require__(1986);
+      const _usemergedref = __webpack_require__(1798);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 1986: /***/ (module, exports, __webpack_require__) => {
+    /***/ 1798: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -432,7 +432,7 @@
       /***/
     },
 
-    /***/ 4193: /***/ (
+    /***/ 3525: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -448,9 +448,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(8332);
-      const _imageblursvg = __webpack_require__(2200);
-      const _imageconfig = __webpack_require__(5388);
+      const _warnonce = __webpack_require__(6976);
+      const _imageblursvg = __webpack_require__(8364);
+      const _imageconfig = __webpack_require__(7256);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -824,7 +824,7 @@
       /***/
     },
 
-    /***/ 2200: /***/ (__unused_webpack_module, exports) => {
+    /***/ 8364: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -879,7 +879,7 @@
       /***/
     },
 
-    /***/ 6797: /***/ (
+    /***/ 9185: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -906,10 +906,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(1739);
-      const _getimgprops = __webpack_require__(4193);
-      const _imagecomponent = __webpack_require__(3317);
+      const _getimgprops = __webpack_require__(3525);
+      const _imagecomponent = __webpack_require__(2465);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(3997)
+        __webpack_require__(617)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -941,7 +941,7 @@
       /***/
     },
 
-    /***/ 3997: /***/ (__unused_webpack_module, exports) => {
+    /***/ 617: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -976,7 +976,7 @@
       /***/
     },
 
-    /***/ 9071: /***/ (
+    /***/ 865: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -993,8 +993,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(9901);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-5c56b873-20241107_re_4mwva3jlwiucd47fxfib3s2p5u/node_modules/next/image.js
-      var next_image = __webpack_require__(9384);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-5c56b873-20241107_re_zlwfy6bhevrbsruir3sxzwvepy/node_modules/next/image.js
+      var next_image = __webpack_require__(6523);
       var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // ./pages/nextjs.png
       /* harmony default export */ const nextjs = {
         src: "/_next/static/media/nextjs.cae0b805.png",
@@ -1024,12 +1024,12 @@
       /***/
     },
 
-    /***/ 9384: /***/ (
+    /***/ 6523: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(6797);
+      module.exports = __webpack_require__(9185);
 
       /***/
     },
@@ -1039,7 +1039,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(8493)
+      __webpack_exec__(5118)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Commit: d41d419

Copy link
Member

@ztanner ztanner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other spot we should set this so that it logs the experimental warning when you turn it on (it determines whether or not to warn based on if the set value is different from the default):

https://github.com/acdlite/next.js/blob/d9faf1b3a54c71a1748d18a34ae8d415c5d48226/packages/next/src/server/config-shared.ts#L1034

This will be used to gate a rewrite of the client cache that we've just
started. Eventually it should merge with the PPR rollout, but that's
already in active experimention and we don't want to harm the PPR
rollout. This will also let us incrementally get to parity with the
existing implementation, instead of trying to reach parity in one
big step.

When enabled (and when a route is using PPR), prefetches will use a new
per-segment cache instead of the existing per-page cache.
@acdlite acdlite requested a review from ztanner November 12, 2024 18:00
@ijjk
Copy link
Member

ijjk commented Nov 12, 2024

Tests Passed

@acdlite acdlite enabled auto-merge (squash) November 12, 2024 19:28
@acdlite acdlite merged commit 2b5d897 into vercel:canary Nov 12, 2024
86 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants