Skip to content

Commit f3e264f

Browse files
jeswrclaude
andcommitted
docs: shorten cache interceptor comments
Addresses review feedback by trimming the stale-if-error comments to terse one-liners in line with the surrounding interceptor style; comment-only, no logic change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e18c736 commit f3e264f

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

lib/handler/cache-revalidation-handler.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ class CacheRevalidationHandler {
109109
}
110110

111111
if (this.#callback) {
112-
// If the response hasn't started yet and we're within the
113-
// stale-if-error threshold, serve the stale cached response instead
114-
// of failing the request. RFC 5861 defines an error as "any situation
115-
// that would result in a 500, 502, 503, or 504 HTTP response status
116-
// code being returned", which includes failing to reach the origin.
112+
// Serve the stale cached response on a connection error, per stale-if-error:
113+
// RFC 5861 counts an unreachable origin (a would-be 5xx) as an error.
117114
// https://datatracker.ietf.org/doc/html/rfc5861#section-4
118115
if (this.#allowErrorStatusCodes) {
119116
this.#successful = true

test/interceptors/cache.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,7 @@ describe('Cache Interceptor', () => {
862862

863863
clock.tick(15000)
864864

865-
// Send second request. The response is stale and the origin is
866-
// unreachable, but we're within the stale-if-error threshold so the
867-
// stale response should still be served.
868-
// https://datatracker.ietf.org/doc/html/rfc5861#section-4
865+
// Stale response, origin unreachable, but within stale-if-error: still served.
869866
{
870867
const response = await client.request(request)
871868
equal(requestsToOrigin, 1)
@@ -1561,9 +1558,7 @@ describe('Cache Interceptor', () => {
15611558

15621559
clock.tick(15000)
15631560

1564-
// Send second request. The response is stale and the origin is
1565-
// unreachable, but the request allows stale-if-error so the stale
1566-
// response should still be served.
1561+
// Stale response, origin unreachable, but request allows stale-if-error: still served.
15671562
{
15681563
const response = await client.request({
15691564
origin: 'localhost',

0 commit comments

Comments
 (0)