From e852476c3f7edf1ed4f8a3d87a7ce110acf6cb34 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 31 Jul 2023 21:15:05 +0800 Subject: [PATCH] docs(academy): Fix code example (#544) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the cache exists and is not expired, then we skip updating. Right? --------- Co-authored-by: Martin Adámek --- .../academy/tutorials/node_js/caching_responses_in_puppeteer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/academy/tutorials/node_js/caching_responses_in_puppeteer.md b/sources/academy/tutorials/node_js/caching_responses_in_puppeteer.md index 21b8f8c0b..cb580b5a2 100644 --- a/sources/academy/tutorials/node_js/caching_responses_in_puppeteer.md +++ b/sources/academy/tutorials/node_js/caching_responses_in_puppeteer.md @@ -71,7 +71,7 @@ page.on('response', async (response) => { const maxAgeMatch = cacheControl.match(/max-age=(\d+)/); const maxAge = maxAgeMatch && maxAgeMatch.length > 1 ? parseInt(maxAgeMatch[1], 10) : 0; if (maxAge) { - if (!cache[url] || cache[url].expires > Date.now()) return; + if (cache[url] && cache[url].expires > Date.now()) return; let buffer; try {