Skip to content

Commit 4aa3164

Browse files
EC2 Default Userclaude
andcommitted
docs: shorten cache interceptor comments
Collapse the multi-sentence comments introduced by this PR to the terse, single-line style used elsewhere in lib/interceptor, keeping the RFC 9111 references. Addresses proactive review feedback on comment terseness. No logic change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c83e67d commit 4aa3164

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

lib/handler/cache-handler.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ const NOT_UNDERSTOOD_STATUS_CODES = [
2626

2727
const MAX_RESPONSE_AGE = 2147483647000
2828

29-
// How long revalidation-only entries (zero freshness lifetime but a validator
30-
// present, e.g. `cache-control: no-cache` or `max-age=0` with an etag) are
31-
// retained so there is something to revalidate against. Every successful
32-
// revalidation re-stores the entry, sliding this window.
29+
// Retention for revalidation-only entries (zero freshness lifetime but a
30+
// validator present); each successful revalidation re-stores the entry.
3331
const REVALIDATION_ONLY_RETENTION = 86400000 // 24 hours
3432

3533
/**
@@ -169,10 +167,8 @@ class CacheHandler {
169167

170168
const baseTime = resDate ? resDate.getTime() : now
171169
const absoluteStaleAt = staleAt + baseTime
172-
// Responses with a zero freshness lifetime but a validator (e.g.
173-
// `cache-control: no-cache` or `max-age=0` with an etag) are stale from
174-
// the start, but they're still storable - each reuse is preceded by a
175-
// revalidation request.
170+
// Zero freshness lifetime but a validator: stale from the start, yet still
171+
// storable since each reuse is preceded by a revalidation request.
176172
// https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2.4
177173
const revalidationOnly = staleAt === 0 && hasValidator
178174
if (now >= absoluteStaleAt && !revalidationOnly) {
@@ -454,8 +450,7 @@ function determineStaleAt (cacheType, now, age, resHeaders, responseDate, cacheC
454450
return sMaxAge * 1000
455451
}
456452

457-
// An immediately stale response can still be stored if we can
458-
// revalidate it before reuse
453+
// Immediately stale, but storable if we can revalidate it before reuse.
459454
return sMaxAge === 0 && hasValidator ? 0 : undefined
460455
}
461456
}
@@ -466,8 +461,7 @@ function determineStaleAt (cacheType, now, age, resHeaders, responseDate, cacheC
466461
return maxAge * 1000
467462
}
468463

469-
// An immediately stale response can still be stored if we can revalidate
470-
// it before reuse
464+
// Immediately stale, but storable if we can revalidate it before reuse.
471465
return maxAge === 0 && hasValidator ? 0 : undefined
472466
}
473467

@@ -513,8 +507,7 @@ function determineStaleAt (cacheType, now, age, resHeaders, responseDate, cacheC
513507
}
514508

515509
if (cacheControlDirectives['no-cache'] === true && hasValidator) {
516-
// The response has no freshness source, but, since it has a validator,
517-
// it can still be stored and revalidated before each reuse
510+
// No freshness source, but a validator lets us revalidate before reuse.
518511
// https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2.4
519512
return 0
520513
}
@@ -556,11 +549,8 @@ function determineDeleteAt (baseTime, cachedAt, cacheControlDirectives, staleAt)
556549
if (staleWhileRevalidate === -Infinity && staleIfError === -Infinity && immutable === -Infinity) {
557550
const freshnessLifetime = staleAt - baseTime
558551
if (freshnessLifetime <= 0) {
559-
// Revalidation-only entry (zero freshness lifetime, stored solely so
560-
// reuses can be revalidated with a conditional request): there's no
561-
// freshness lifetime to base the buffer on, so retain it for a bounded
562-
// window instead. Every successful revalidation re-stores the entry,
563-
// sliding the window.
552+
// Revalidation-only entry: no freshness lifetime to size the buffer on,
553+
// so retain it for a bounded window instead.
564554
return cachedAt + REVALIDATION_ONLY_RETENTION
565555
}
566556
const datePrecisionPadding = Math.min(Math.max(cachedAt - baseTime, 0), 1000)

0 commit comments

Comments
 (0)