From b979a27d6f5839513d48fec3dcd4b9ddb5fab030 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 6 Nov 2024 09:58:38 +0000 Subject: [PATCH] WIP --- lib/handler/cache-handler.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 8e56a5769b6..9a116ffa2d7 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -93,15 +93,16 @@ class CacheHandler extends DecoratorHandler { const headers = util.parseHeaders(rawHeaders) const cacheControlHeader = headers['cache-control'] - const contentLengthHeader = headers['content-length'] - - if (!cacheControlHeader || !contentLengthHeader || this.#store.isFull) { - // Don't have the headers we need, can't cache + if (!cacheControlHeader || typeof cacheControlHeader !== 'string') { + // Don't have cache-control, can't cache. return downstreamOnHeaders() } - const contentLength = Number(contentLengthHeader) + const contentLengthHeader = headers['content-length'] + const contentLength = contentLengthHeader ? Number(contentLengthHeader) : null if (!Number.isInteger(contentLength)) { + // Don't know the final size, don't cache. + // TODO (fix): Why not cache? return downstreamOnHeaders() }