This commit is contained in:
mark committed 2026-09-04 11:52:10 -04:00
1 parent 6925c46568
commit 7127e3ff9d
27 files changed
+721 -676

No files matched your search

+15 -2
View File
@@ -213,6 +213,19 @@ async function answer(input, event) {
}
}
// Pages are always asked for with revalidation forced.
//
// server.py marks them no-cache, which asks the browser for the same thing --
// but this worker's own fetch goes through the browser's HTTP cache too, so a
// page stored under an earlier and wronger Cache-Control keeps being served
// from it until that entry expires, however many times the library version
// changes underneath. Saying it on the request is what gets past one that
// already is. Costs a conditional GET, which the response header was asking
// for anyway.
function pageRequest(url) {
return new Request(url, { cache: 'no-cache' });
}
async function readText(input, event) {
const res = await answer(input, event);
if (!res || !res.ok) throw new Error('cannot load ' + (input.url || input));
@@ -250,7 +263,7 @@ const MISSING_NOTICE = ['Not found', 'There is no page at this address.'];
async function fragmentFor(path, event) {
let res;
try {
res = await answer(path, event);
res = await answer(pageRequest(path), event);
} catch (err) {
return view.notice(...OFFLINE_NOTICE);
}
@@ -335,7 +348,7 @@ async function fillLibrary() {
while (missing.length && !stopped) {
const url = missing.pop();
try {
const res = await fromNetwork(new Request(url), DOWNLOAD_TIMEOUT_MS);
const res = await fromNetwork(pageRequest(url), DOWNLOAD_TIMEOUT_MS);
// A response that arrived but is not usable -- a page that has since
// been removed, say -- is skipped rather than retried. The connection
// is plainly fine, and stopping for it would strand everything after.