@@ -16,24 +16,20 @@ import {
1616} from './tags-handler.cjs'
1717import { getTracer } from './tracer.cjs'
1818
19- // copied from default implementation
20- // packages/next/src/server/lib/cache-handlers/default.ts
19+ // Most of this code is copied and adapted from Next.js default 'use cache' handler implementation
20+ // https://github.com/vercel/next.js/blob/84fde91e03918344c5d356986914ab68a5083462/packages/next/src/server/lib/cache-handlers/default.ts
21+ // this includes:
22+ // - PrivateCacheEntry (with removed `isErrored` and `errorRetryCount` as those are not actually used there)
23+ // - Main logic of .get and .set methods
24+ // Main difference is:
25+ // - Tag handling - default Next.js implementation handles tags in memory only, but we need to support tag
26+ // invalidation cross serverless instances, so we do use same persistent storage as we use for response and fetch cache
27+ // Additionally we do not actually implement refreshTags to update in-memory tag manifest as this operation is blocking
28+ // and our serverless instances also can handle any page template so implementing it would not have good perf tradeoffs
29+ // - Addition of tracing
30+
2131type PrivateCacheEntry = {
2232 entry : CacheEntry
23-
24- // For the default cache we store errored cache
25- // entries and allow them to be used up to 3 times
26- // after that we want to dispose it and try for fresh
27-
28- // If an entry is errored we return no entry
29- // three times so that we retry hitting origin (MISS)
30- // and then if it still fails to set after the third we
31- // return the errored content and use expiration of
32- // Math.min(30, entry.expiration)
33-
34- isErrored : boolean // pieh: this doesn't seem to be actually used in the default implementation
35- errorRetryCount : number // pieh: this doesn't seem to be actually used in the default implementation
36-
3733 // compute size on set since we need to read size
3834 // of the ReadableStream for LRU evicting
3935 size : number
@@ -207,8 +203,6 @@ export const NetlifyDefaultUseCacheHandler = {
207203
208204 getLRUCache ( ) . set ( cacheKey , {
209205 entry,
210- isErrored : false ,
211- errorRetryCount : 0 ,
212206 size,
213207 } )
214208 } catch ( error ) {
0 commit comments