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 default cache handlers and update tags manifest handling #71455

Merged
merged 12 commits into from
Oct 19, 2024

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Oct 17, 2024

This breaks the default cache handler out from the use-cache-wrapper and starts wiring up the config so we can provide custom handlers. This does not make custom ones able to be leveraged yet that will come in a follow-up and inject them.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. type: next labels Oct 17, 2024
Copy link

socket-security bot commented Oct 17, 2024

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/@types/lru-cache@5.1.0

View full report↗︎

@ijjk
Copy link
Member Author

ijjk commented Oct 17, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
buildDuration 17.7s 16.1s N/A
buildDurationCached 15.4s 13s N/A
nodeModulesSize 372 MB 372 MB N/A
nextStartRea..uration (ms) 429ms 428ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
1193.HASH.js gzip 168 B 168 B
1495-HASH.js gzip 5.27 kB 5.27 kB N/A
9073-HASH.js gzip 44.2 kB 44.2 kB N/A
d4c1d954-HASH.js gzip 52.6 kB 52.6 kB N/A
framework-HASH.js gzip 57.4 kB 57.4 kB N/A
main-app-HASH.js gzip 237 B 236 B N/A
main-HASH.js gzip 32.8 kB 32.8 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 168 B 168 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers 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 vercel/next.js ijjk/experimental-cache-handlers Change
_app-HASH.js gzip 192 B 193 B N/A
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 511 B 510 B N/A
css-HASH.js gzip 341 B 343 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB N/A
edge-ssr-HASH.js gzip 266 B 266 B
head-HASH.js gzip 364 B 364 B
hooks-HASH.js gzip 391 B 391 B
image-HASH.js gzip 4.41 kB 4.4 kB N/A
index-HASH.js gzip 269 B 268 B N/A
link-HASH.js gzip 2.78 kB 2.78 kB N/A
routerDirect..HASH.js gzip 328 B 327 B N/A
script-HASH.js gzip 397 B 395 B N/A
withRouter-HASH.js gzip 324 B 322 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.32 kB 1.32 kB
Client Build Manifests
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
_buildManifest.js gzip 746 B 749 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
index.html gzip 522 B 523 B N/A
link.html gzip 535 B 536 B N/A
withRouter.html gzip 518 B 519 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
edge-ssr.js gzip 130 kB 128 kB N/A
page.js gzip 189 kB 187 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
middleware-b..fest.js gzip 665 B 671 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 vercel/next.js ijjk/experimental-cache-handlers Change
973-experime...dev.js gzip 322 B 322 B
973.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 314 kB 314 kB
app-page-exp..prod.js gzip 121 kB 121 kB
app-page-tur..prod.js gzip 134 kB 134 kB
app-page-tur..prod.js gzip 129 kB 129 kB
app-page.run...dev.js gzip 304 kB 304 kB
app-page.run..prod.js gzip 116 kB 116 kB
app-route-ex...dev.js gzip 35.9 kB 35.9 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.5 kB 37.5 kB
app-route.ru..prod.js gzip 24.2 kB 24.2 kB
pages-api-tu..prod.js gzip 9.61 kB 9.61 kB
pages-api.ru...dev.js gzip 11.4 kB 11.4 kB
pages-api.ru..prod.js gzip 9.61 kB 9.61 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 60.4 kB 58.1 kB N/A
Overall change 1.39 MB 1.39 MB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js ijjk/experimental-cache-handlers Change
0.pack gzip 1.84 MB 1.84 MB ⚠️ +3.94 kB
index.pack gzip 142 kB 144 kB ⚠️ +1.79 kB
Overall change 1.98 MB 1.99 MB ⚠️ +5.73 kB
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 image-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [8358],
   {
-    /***/ 771: /***/ (
+    /***/ 2258: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(5653);
+          return __webpack_require__(142);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 5267: /***/ (module, exports, __webpack_require__) => {
+    /***/ 9936: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,17 +40,17 @@
         __webpack_require__(755)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(3489)
+        __webpack_require__(2183)
       );
-      const _getimgprops = __webpack_require__(5537);
-      const _imageconfig = __webpack_require__(8868);
-      const _imageconfigcontextsharedruntime = __webpack_require__(7610);
-      const _warnonce = __webpack_require__(2332);
-      const _routercontextsharedruntime = __webpack_require__(3445);
+      const _getimgprops = __webpack_require__(6561);
+      const _imageconfig = __webpack_require__(9706);
+      const _imageconfigcontextsharedruntime = __webpack_require__(3188);
+      const _warnonce = __webpack_require__(5157);
+      const _routercontextsharedruntime = __webpack_require__(1511);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6376)
+        __webpack_require__(320)
       );
-      const _usemergedref = __webpack_require__(3768);
+      const _usemergedref = __webpack_require__(8118);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 3768: /***/ (module, exports, __webpack_require__) => {
+    /***/ 8118: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -432,7 +432,7 @@
       /***/
     },
 
-    /***/ 5537: /***/ (
+    /***/ 6561: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -448,9 +448,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(2332);
-      const _imageblursvg = __webpack_require__(7988);
-      const _imageconfig = __webpack_require__(8868);
+      const _warnonce = __webpack_require__(5157);
+      const _imageblursvg = __webpack_require__(9002);
+      const _imageconfig = __webpack_require__(9706);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -824,7 +824,7 @@
       /***/
     },
 
-    /***/ 7988: /***/ (__unused_webpack_module, exports) => {
+    /***/ 9002: /***/ (__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 @@
       /***/
     },
 
-    /***/ 8208: /***/ (
+    /***/ 6821: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -906,10 +906,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(9608);
-      const _getimgprops = __webpack_require__(5537);
-      const _imagecomponent = __webpack_require__(5267);
+      const _getimgprops = __webpack_require__(6561);
+      const _imagecomponent = __webpack_require__(9936);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6376)
+        __webpack_require__(320)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -941,7 +941,7 @@
       /***/
     },
 
-    /***/ 6376: /***/ (__unused_webpack_module, exports) => {
+    /***/ 320: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -976,7 +976,7 @@
       /***/
     },
 
-    /***/ 5653: /***/ (
+    /***/ 142: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -993,8 +993,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/react@19.0.0-rc-bf7e210c-20241017/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(9166);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-bf7e210c-20241017_re_s3utpgylidq4iuqtuhvaikn7r4/node_modules/next/image.js
-      var next_image = __webpack_require__(6812);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-bf7e210c-20241017_re_z36suzq4wvowgbcnr6zytfoqpy/node_modules/next/image.js
+      var next_image = __webpack_require__(9101);
       var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // CONCATENATED MODULE: ./pages/nextjs.png
       /* harmony default export */ const nextjs = {
         src: "/_next/static/media/nextjs.cae0b805.png",
@@ -1024,12 +1024,12 @@
       /***/
     },
 
-    /***/ 6812: /***/ (
+    /***/ 9101: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(8208);
+      module.exports = __webpack_require__(6821);
 
       /***/
     },
@@ -1039,7 +1039,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
-      __webpack_exec__(771)
+      __webpack_exec__(2258)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for server.runtime.prod.js

Diff too large to display

Commit: f1b7c12

size?: number
}

export class DefaultCacheHandler implements CacheHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use a singleton instead of classes. No need to instantiate new ones all the time.

tags: string[]
// This is for the client not used to calculate
// cache entry expiration
staleTime: number
Copy link
Contributor

Choose a reason for hiding this comment

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

this is called stale now since that's what the config option is called on cacheLife.

https://github.com/vercel/next.js/blob/canary/packages/next/src/server/use-cache/use-cache-wrapper.ts#L41-L53

@@ -1 +1 @@
(()=>{"use strict";var t={806:(t,e,i)=>{const s=i(190);const n=Symbol("max");const l=Symbol("length");const r=Symbol("lengthCalculator");const h=Symbol("allowStale");const a=Symbol("maxAge");const o=Symbol("dispose");const u=Symbol("noDisposeOnSet");const f=Symbol("lruList");const p=Symbol("cache");const v=Symbol("updateAgeOnGet");const naiveLength=()=>1;class LRUCache{constructor(t){if(typeof t==="number")t={max:t};if(!t)t={};if(t.max&&(typeof t.max!=="number"||t.max<0))throw new TypeError("max must be a non-negative number");const e=this[n]=t.max||Infinity;const i=t.length||naiveLength;this[r]=typeof i!=="function"?naiveLength:i;this[h]=t.stale||false;if(t.maxAge&&typeof t.maxAge!=="number")throw new TypeError("maxAge must be a number");this[a]=t.maxAge||0;this[o]=t.dispose;this[u]=t.noDisposeOnSet||false;this[v]=t.updateAgeOnGet||false;this.reset()}set max(t){if(typeof t!=="number"||t<0)throw new TypeError("max must be a non-negative number");this[n]=t||Infinity;trim(this)}get max(){return this[n]}set allowStale(t){this[h]=!!t}get allowStale(){return this[h]}set maxAge(t){if(typeof t!=="number")throw new TypeError("maxAge must be a non-negative number");this[a]=t;trim(this)}get maxAge(){return this[a]}set lengthCalculator(t){if(typeof t!=="function")t=naiveLength;if(t!==this[r]){this[r]=t;this[l]=0;this[f].forEach((t=>{t.length=this[r](t.value,t.key);this[l]+=t.length}))}trim(this)}get lengthCalculator(){return this[r]}get length(){return this[l]}get itemCount(){return this[f].length}rforEach(t,e){e=e||this;for(let i=this[f].tail;i!==null;){const s=i.prev;forEachStep(this,t,i,e);i=s}}forEach(t,e){e=e||this;for(let i=this[f].head;i!==null;){const s=i.next;forEachStep(this,t,i,e);i=s}}keys(){return this[f].toArray().map((t=>t.key))}values(){return this[f].toArray().map((t=>t.value))}reset(){if(this[o]&&this[f]&&this[f].length){this[f].forEach((t=>this[o](t.key,t.value)))}this[p]=new Map;this[f]=new s;this[l]=0}dump(){return this[f].map((t=>isStale(this,t)?false:{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[f]}set(t,e,i){i=i||this[a];if(i&&typeof i!=="number")throw new TypeError("maxAge must be a number");const s=i?Date.now():0;const h=this[r](e,t);if(this[p].has(t)){if(h>this[n]){del(this,this[p].get(t));return false}const r=this[p].get(t);const a=r.value;if(this[o]){if(!this[u])this[o](t,a.value)}a.now=s;a.maxAge=i;a.value=e;this[l]+=h-a.length;a.length=h;this.get(t);trim(this);return true}const v=new Entry(t,e,h,s,i);if(v.length>this[n]){if(this[o])this[o](t,e);return false}this[l]+=v.length;this[f].unshift(v);this[p].set(t,this[f].head);trim(this);return true}has(t){if(!this[p].has(t))return false;const e=this[p].get(t).value;return!isStale(this,e)}get(t){return get(this,t,true)}peek(t){return get(this,t,false)}pop(){const t=this[f].tail;if(!t)return null;del(this,t);return t.value}del(t){del(this,this[p].get(t))}load(t){this.reset();const e=Date.now();for(let i=t.length-1;i>=0;i--){const s=t[i];const n=s.e||0;if(n===0)this.set(s.k,s.v);else{const t=n-e;if(t>0){this.set(s.k,s.v,t)}}}}prune(){this[p].forEach(((t,e)=>get(this,e,false)))}}const get=(t,e,i)=>{const s=t[p].get(e);if(s){const e=s.value;if(isStale(t,e)){del(t,s);if(!t[h])return undefined}else{if(i){if(t[v])s.value.now=Date.now();t[f].unshiftNode(s)}}return e.value}};const isStale=(t,e)=>{if(!e||!e.maxAge&&!t[a])return false;const i=Date.now()-e.now;return e.maxAge?i>e.maxAge:t[a]&&i>t[a]};const trim=t=>{if(t[l]>t[n]){for(let e=t[f].tail;t[l]>t[n]&&e!==null;){const i=e.prev;del(t,e);e=i}}};const del=(t,e)=>{if(e){const i=e.value;if(t[o])t[o](i.key,i.value);t[l]-=i.length;t[p].delete(i.key);t[f].removeNode(e)}};class Entry{constructor(t,e,i,s,n){this.key=t;this.value=e;this.length=i;this.now=s;this.maxAge=n||0}}const forEachStep=(t,e,i,s)=>{let n=i.value;if(isStale(t,n)){del(t,i);if(!t[h])n=undefined}if(n)e.call(s,n.value,n.key,t)};t.exports=LRUCache},76:t=>{t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next){yield t.value}}}},190:(t,e,i)=>{t.exports=Yallist;Yallist.Node=Node;Yallist.create=Yallist;function Yallist(t){var e=this;if(!(e instanceof Yallist)){e=new Yallist}e.tail=null;e.head=null;e.length=0;if(t&&typeof t.forEach==="function"){t.forEach((function(t){e.push(t)}))}else if(arguments.length>0){for(var i=0,s=arguments.length;i<s;i++){e.push(arguments[i])}}return e}Yallist.prototype.removeNode=function(t){if(t.list!==this){throw new Error("removing node which does not belong to this list")}var e=t.next;var i=t.prev;if(e){e.prev=i}if(i){i.next=e}if(t===this.head){this.head=e}if(t===this.tail){this.tail=i}t.list.length--;t.next=null;t.prev=null;t.list=null;return e};Yallist.prototype.unshiftNode=function(t){if(t===this.head){return}if(t.list){t.list.removeNode(t)}var e=this.head;t.list=this;t.next=e;if(e){e.prev=t}this.head=t;if(!this.tail){this.tail=t}this.length++};Yallist.prototype.pushNode=function(t){if(t===this.tail){return}if(t.list){t.list.removeNode(t)}var e=this.tail;t.list=this;t.prev=e;if(e){e.next=t}this.tail=t;if(!this.head){this.head=t}this.length++};Yallist.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++){push(this,arguments[t])}return this.length};Yallist.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++){unshift(this,arguments[t])}return this.length};Yallist.prototype.pop=function(){if(!this.tail){return undefined}var t=this.tail.value;this.tail=this.tail.prev;if(this.tail){this.tail.next=null}else{this.head=null}this.length--;return t};Yallist.prototype.shift=function(){if(!this.head){return undefined}var t=this.head.value;this.head=this.head.next;if(this.head){this.head.prev=null}else{this.tail=null}this.length--;return t};Yallist.prototype.forEach=function(t,e){e=e||this;for(var i=this.head,s=0;i!==null;s++){t.call(e,i.value,s,this);i=i.next}};Yallist.prototype.forEachReverse=function(t,e){e=e||this;for(var i=this.tail,s=this.length-1;i!==null;s--){t.call(e,i.value,s,this);i=i.prev}};Yallist.prototype.get=function(t){for(var e=0,i=this.head;i!==null&&e<t;e++){i=i.next}if(e===t&&i!==null){return i.value}};Yallist.prototype.getReverse=function(t){for(var e=0,i=this.tail;i!==null&&e<t;e++){i=i.prev}if(e===t&&i!==null){return i.value}};Yallist.prototype.map=function(t,e){e=e||this;var i=new Yallist;for(var s=this.head;s!==null;){i.push(t.call(e,s.value,this));s=s.next}return i};Yallist.prototype.mapReverse=function(t,e){e=e||this;var i=new Yallist;for(var s=this.tail;s!==null;){i.push(t.call(e,s.value,this));s=s.prev}return i};Yallist.prototype.reduce=function(t,e){var i;var s=this.head;if(arguments.length>1){i=e}else if(this.head){s=this.head.next;i=this.head.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var n=0;s!==null;n++){i=t(i,s.value,n);s=s.next}return i};Yallist.prototype.reduceReverse=function(t,e){var i;var s=this.tail;if(arguments.length>1){i=e}else if(this.tail){s=this.tail.prev;i=this.tail.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var n=this.length-1;s!==null;n--){i=t(i,s.value,n);s=s.prev}return i};Yallist.prototype.toArray=function(){var t=new Array(this.length);for(var e=0,i=this.head;i!==null;e++){t[e]=i.value;i=i.next}return t};Yallist.prototype.toArrayReverse=function(){var t=new Array(this.length);for(var e=0,i=this.tail;i!==null;e++){t[e]=i.value;i=i.prev}return t};Yallist.prototype.slice=function(t,e){e=e||this.length;if(e<0){e+=this.length}t=t||0;if(t<0){t+=this.length}var i=new Yallist;if(e<t||e<0){return i}if(t<0){t=0}if(e>this.length){e=this.length}for(var s=0,n=this.head;n!==null&&s<t;s++){n=n.next}for(;n!==null&&s<e;s++,n=n.next){i.push(n.value)}return i};Yallist.prototype.sliceReverse=function(t,e){e=e||this.length;if(e<0){e+=this.length}t=t||0;if(t<0){t+=this.length}var i=new Yallist;if(e<t||e<0){return i}if(t<0){t=0}if(e>this.length){e=this.length}for(var s=this.length,n=this.tail;n!==null&&s>e;s--){n=n.prev}for(;n!==null&&s>t;s--,n=n.prev){i.push(n.value)}return i};Yallist.prototype.splice=function(t,e){if(t>this.length){t=this.length-1}if(t<0){t=this.length+t}for(var i=0,s=this.head;s!==null&&i<t;i++){s=s.next}var n=[];for(var i=0;s&&i<e;i++){n.push(s.value);s=this.removeNode(s)}if(s===null){s=this.tail}if(s!==this.head&&s!==this.tail){s=s.prev}for(var i=2;i<arguments.length;i++){s=insert(this,s,arguments[i])}return n};Yallist.prototype.reverse=function(){var t=this.head;var e=this.tail;for(var i=t;i!==null;i=i.prev){var s=i.prev;i.prev=i.next;i.next=s}this.head=e;this.tail=t;return this};function insert(t,e,i){var s=e===t.head?new Node(i,null,e,t):new Node(i,e,e.next,t);if(s.next===null){t.tail=s}if(s.prev===null){t.head=s}t.length++;return s}function push(t,e){t.tail=new Node(e,t.tail,null,t);if(!t.head){t.head=t.tail}t.length++}function unshift(t,e){t.head=new Node(e,null,t.head,t);if(!t.tail){t.tail=t.head}t.length++}function Node(t,e,i,s){if(!(this instanceof Node)){return new Node(t,e,i,s)}this.list=s;this.value=t;if(e){e.next=this;this.prev=e}else{this.prev=null}if(i){i.prev=this;this.next=i}else{this.next=null}}try{i(76)(Yallist)}catch(t){}}};var e={};function __nccwpck_require__(i){var s=e[i];if(s!==undefined){return s.exports}var n=e[i]={exports:{}};var l=true;try{t[i](n,n.exports,__nccwpck_require__);l=false}finally{if(l)delete e[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(806);module.exports=i})();
Copy link
Contributor

Choose a reason for hiding this comment

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

rm this whole file?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the old vendor'ed one we can just use the minimal one which handles our specific LRU uses

// compute size on set since we need to read size
// of the ReadableStream for LRU evicting
size?: number
}
Copy link
Contributor

@sebmarkbage sebmarkbage Oct 18, 2024

Choose a reason for hiding this comment

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

If we extend the cache entries we end up with different hidden classes in the code when more than one cache handler is active which would cause that code to deopt, thrash the JIT and eventually stable out in a sub-optimal polymorphic state.

It's better that we compose them instead. (Also just composition > inheritance in general.)

For example:

type DefaultCacheEntry = {
  entry: CacheEntry,
  isErrored: boolean
  errorRetryCount: number
  size?: number
}

This also makes it clearer which are internals of this and never could possibly leak outside the implementation of the cache handler into the implementation of use-cache-wrapper.

@ijjk ijjk marked this pull request as ready for review October 18, 2024 22:30
Copy link

vercel bot commented Oct 18, 2024

Notifying the following users due to files changed in this PR based on this repo's notify modifiers:

@timneutkens, @shuding, @huozhi:

packages/next/src/server/config.ts

@ijjk ijjk changed the title Add experimental config for cache handlers Add default cache handlers and update tags manifest handling Oct 18, 2024
@ijjk ijjk merged commit c228a6e into canary Oct 19, 2024
99 of 107 checks passed
@ijjk ijjk deleted the ijjk/experimental-cache-handlers branch October 19, 2024 00:13
ijjk added a commit that referenced this pull request Oct 19, 2024
Follow-up to #71455 this adds
wiring up for the cache handlers config and exposing it to
use-cache-wrapper. Also adds mapping of remote -> default cache handler
for dev.
@github-actions github-actions bot added the locked label Nov 2, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 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.

2 participants