Dirty hack to turn off wrong caching of AntiZapret

This commit is contained in:
ilyaigpetrov 2020-06-05 15:15:13 +00:00
parent 94b4261418
commit 84902d8e5a
2 changed files with 9 additions and 2 deletions

View File

@ -146,7 +146,14 @@
httpLib.ifModifiedSince(pacUrl, lastModifiedStr, (err, newLastModifiedStr) => {
if (!newLastModifiedStr) {
const ifWasEverModified = lastModifiedStr !== new Date(0).toUTCString();
/*
TODO: Get rid of this dirty hack
IPFS used by AntiZapret always returns last-modified date as new Date(1000) which is 1 sec since unix epoch.
Last-modified isn't changed but target redireciton URL is and this URL should be compared to the last cached URL.
Hack here is to consider 5 seconds since epoch time the same way as the unix epoch start.
If you think etags are the solution then know that etags can't be read from the fetch API, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers.
*/
const ifWasEverModified = new Date(lastModifiedStr) - new Date(0) > 5000;
if (ifWasEverModified) {
addWarning(

View File

@ -6,7 +6,7 @@
"description": "__MSG_extDesc__",
"version": "0.0.${version}",
"icons": {
"128": "/icons/default-128.png"
"128": "icons/default-128.png"
},
"author": "anticensority+owners@googlegroups.com",