1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

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:
Raymond Hill 2023-10-27 21:09:49 -04:00
parent ed4b31931a
commit 07ac27e07b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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);