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,11 +56,13 @@ const resourceTimeFromXhr = xhr => {
|
|||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Age
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
|
||||
let networkTime = 0;
|
||||
const age = parseInt(xhr.getResponseHeader('Age'), 10);
|
||||
if ( isNaN(age) === false ) {
|
||||
const time = (new Date(xhr.getResponseHeader('Date'))).getTime();
|
||||
if ( isNaN(time) === false ) {
|
||||
networkTime = time - age * 1000;
|
||||
if ( assetTime === 0 ) {
|
||||
const age = parseInt(xhr.getResponseHeader('Age'), 10);
|
||||
if ( isNaN(age) === false ) {
|
||||
const time = (new Date(xhr.getResponseHeader('Date'))).getTime();
|
||||
if ( isNaN(time) === false ) {
|
||||
networkTime = time - age * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Math.max(assetTime, networkTime, 0);
|
||||
|
|
Loading…
Reference in New Issue