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.
This commit is contained in:
Raymond Hill 2019-07-26 09:52:11 -04:00
parent 8d136ec2d5
commit 048bfd251c
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 10 additions and 1 deletions

View file

@ -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 {

View file

@ -58,6 +58,7 @@ const µBlock = (function() { // jshint ignore:line
selfieAfter: 3,
strictBlockingBypassDuration: 120,
suspendTabsUntilReady: 'unset',
updateAssetBypassBrowserCache: false,
userResourcesLocation: 'unset',
};