From cd33a1548fa2d1ad5e714d976b679915d5ec58e1 Mon Sep 17 00:00:00 2001 From: fdumont Date: Tue, 9 May 2023 20:38:04 +0200 Subject: [PATCH] only cache response if response has cache-control header --- packages/adapter-cloudflare/src/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/adapter-cloudflare/src/worker.js b/packages/adapter-cloudflare/src/worker.js index dcdcb9a46efb..6a421a4e9ba9 100644 --- a/packages/adapter-cloudflare/src/worker.js +++ b/packages/adapter-cloudflare/src/worker.js @@ -55,7 +55,8 @@ const worker = { // write to `Cache` only if response is not an error, // let `Cache.save` handle the Cache-Control and Vary headers - return res.status >= 400 ? res : Cache.save(req, res, context); + pragma = res.headers.get('cache-control') || ''; + return pragma && res.status < 400 ? Cache.save(req, res, context) : res; } };