mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Use prime number to generate cache-bypass token
Related discussion: - https://github.com/gorhill/uBlock/commit/048bfd251c9b#r37972005 From <https://github.com/gwarser>: > I think this should be "modulo prime", not 12. > If someone always turn on PC in "8am" there is > a slight chance to hit cache.
This commit is contained in:
parent
086aece6bd
commit
f5204235b7
@ -161,11 +161,14 @@ api.fetchText = async function(url) {
|
|||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130
|
||||||
// Provide filter list authors a way to completely bypass
|
// Provide filter list authors a way to completely bypass
|
||||||
// the browser cache.
|
// the browser cache.
|
||||||
|
// https://github.com/gorhill/uBlock/commit/048bfd251c9b#r37972005
|
||||||
|
// Use modulo prime numbers to avoid generating the same token at the
|
||||||
|
// same time across different days.
|
||||||
if ( isExternal ) {
|
if ( isExternal ) {
|
||||||
const cacheBypassToken =
|
const cacheBypassToken =
|
||||||
µBlock.hiddenSettings.updateAssetBypassBrowserCache
|
µBlock.hiddenSettings.updateAssetBypassBrowserCache
|
||||||
? Math.floor(Date.now() / 1000) % 86400
|
? Math.floor(Date.now() / 1000) % 86413
|
||||||
: Math.floor(Date.now() / 3600000) % 12;
|
: Math.floor(Date.now() / 3600000) % 13;
|
||||||
const queryValue = `_=${cacheBypassToken}`;
|
const queryValue = `_=${cacheBypassToken}`;
|
||||||
if ( actualUrl.indexOf('?') === -1 ) {
|
if ( actualUrl.indexOf('?') === -1 ) {
|
||||||
actualUrl += '?';
|
actualUrl += '?';
|
||||||
|
Loading…
Reference in New Issue
Block a user