From 52925ba2f9ed4351c0f5c7420773d2f59557fc7d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 13 Aug 2019 08:49:37 -0400 Subject: [PATCH] Support disabling advanced setting `cacheControlForFirefox1376932` Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/229#issuecomment-520810161 Setting `cacheControlForFirefox1376932` to `unset` will prevent modification of the `Cache-Control` header. --- src/js/traffic.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js/traffic.js b/src/js/traffic.js index 9b587e3ca..ac77e0e03 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -483,14 +483,16 @@ const onHeadersReceived = function(details) { // Use `no-cache` instead of `no-cache, no-store, must-revalidate`, this // allows Firefox's offline mode to work as expected. if ( (filteredHTML || modifiedHeaders) && dontCacheResponseHeaders ) { - let i = headerIndexFromName('cache-control', responseHeaders); let cacheControl = µb.hiddenSettings.cacheControlForFirefox1376932; - if ( i !== -1 ) { - responseHeaders[i].value = cacheControl; - } else { - responseHeaders.push({ name: 'Cache-Control', value: cacheControl }); + if ( cacheControl !== 'unset' ) { + let i = headerIndexFromName('cache-control', responseHeaders); + if ( i !== -1 ) { + responseHeaders[i].value = cacheControl; + } else { + responseHeaders.push({ name: 'Cache-Control', value: cacheControl }); + } + modifiedHeaders = true; } - modifiedHeaders = true; } if ( modifiedHeaders ) {