Skip to content

Commit 048bfd2

Browse files
committed
Add ability to bypass browser cache when fetching a resource
Related issue: - uBlockOrigin/uBlock-issues#682 (comment) 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.
1 parent 8d136ec commit 048bfd2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/js/assets.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,16 @@ api.fetchText = function(url, onLoad, onError) {
6969
// https://github.com/gorhill/uBlock/issues/2592
7070
// Force browser cache to be bypassed, but only for resources which have
7171
// been fetched more than one hour ago.
72+
//
73+
// https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130
74+
// Provide filter list authors a way to completely bypass
75+
// the browser cache.
7276
if ( isExternal ) {
73-
const queryValue = `_=${Math.floor(Date.now() / 3600000) % 12}`;
77+
const cacheBypassToken =
78+
µBlock.hiddenSettings.updateAssetBypassBrowserCache
79+
? Math.floor(Date.now() / 1000) % 86400
80+
: Math.floor(Date.now() / 3600000) % 12;
81+
const queryValue = `_=${cacheBypassToken}`;
7482
if ( actualUrl.indexOf('?') === -1 ) {
7583
actualUrl += '?';
7684
} else {

src/js/background.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const µBlock = (function() { // jshint ignore:line
5858
selfieAfter: 3,
5959
strictBlockingBypassDuration: 120,
6060
suspendTabsUntilReady: 'unset',
61+
updateAssetBypassBrowserCache: false,
6162
userResourcesLocation: 'unset',
6263
};
6364

0 commit comments

Comments
 (0)