mirror of https://github.com/gorhill/uBlock.git
Give precedence to `Last modified:` field when evaluating "age" if lists
Available network information is not very reliable and should be used only when `Last modified:` is not available.
This commit is contained in:
parent
ed4b31931a
commit
07ac27e07b
|
@ -56,6 +56,7 @@ const resourceTimeFromXhr = xhr => {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Age
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Age
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
|
||||||
let networkTime = 0;
|
let networkTime = 0;
|
||||||
|
if ( assetTime === 0 ) {
|
||||||
const age = parseInt(xhr.getResponseHeader('Age'), 10);
|
const age = parseInt(xhr.getResponseHeader('Age'), 10);
|
||||||
if ( isNaN(age) === false ) {
|
if ( isNaN(age) === false ) {
|
||||||
const time = (new Date(xhr.getResponseHeader('Date'))).getTime();
|
const time = (new Date(xhr.getResponseHeader('Date'))).getTime();
|
||||||
|
@ -63,6 +64,7 @@ const resourceTimeFromXhr = xhr => {
|
||||||
networkTime = time - age * 1000;
|
networkTime = time - age * 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Math.max(assetTime, networkTime, 0);
|
return Math.max(assetTime, networkTime, 0);
|
||||||
} catch(_) {
|
} catch(_) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue