From 048bfd251c9b8eeafce020b4f894d736044d6a6f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 26 Jul 2019 09:52:11 -0400 Subject: [PATCH] Add ability to bypass browser cache when fetching a resource Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130 The following advanced setting has been added: updateAssetBypassBrowserCache Default to `false`. If set to `true`, uBO will ensure the browser cache is bypassed when fetching a remote resource. This is for the convenience of filter list maintainers who may want to test the latest version of their lists when fetched from their remote location. --- src/js/assets.js | 10 +++++++++- src/js/background.js | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/assets.js b/src/js/assets.js index 07700f073..f41300a14 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -69,8 +69,16 @@ api.fetchText = function(url, onLoad, onError) { // https://github.com/gorhill/uBlock/issues/2592 // Force browser cache to be bypassed, but only for resources which have // been fetched more than one hour ago. + // + // https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130 + // Provide filter list authors a way to completely bypass + // the browser cache. if ( isExternal ) { - const queryValue = `_=${Math.floor(Date.now() / 3600000) % 12}`; + const cacheBypassToken = + µBlock.hiddenSettings.updateAssetBypassBrowserCache + ? Math.floor(Date.now() / 1000) % 86400 + : Math.floor(Date.now() / 3600000) % 12; + const queryValue = `_=${cacheBypassToken}`; if ( actualUrl.indexOf('?') === -1 ) { actualUrl += '?'; } else { diff --git a/src/js/background.js b/src/js/background.js index d38724349..68a7fed24 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -58,6 +58,7 @@ const µBlock = (function() { // jshint ignore:line selfieAfter: 3, strictBlockingBypassDuration: 120, suspendTabsUntilReady: 'unset', + updateAssetBypassBrowserCache: false, userResourcesLocation: 'unset', };