+9
-7
src/pages.go
+9
-7
src/pages.go
···
417
417
io.Copy(w, reader)
418
418
}
419
419
} else {
420
-
// consider content fresh for 60 seconds (the same as the freshness interval of
421
-
// manifests in the S3 backend), and use stale content anyway as long as it's not
422
-
// older than a hour; while it is cheap to handle If-Modified-Since queries
423
-
// server-side, on the client `max-age=0, must-revalidate` causes every resource
424
-
// to block the page load every time
425
-
w.Header().Set("Cache-Control", "max-age=60, stale-while-revalidate=3600")
426
-
// see https://web.dev/articles/stale-while-revalidate for details
420
+
if _, hasCacheControl := w.Header()["Cache-Control"]; !hasCacheControl {
421
+
// consider content fresh for 60 seconds (the same as the freshness interval of
422
+
// manifests in the S3 backend), and use stale content anyway as long as it's not
423
+
// older than a hour; while it is cheap to handle If-Modified-Since queries
424
+
// server-side, on the client `max-age=0, must-revalidate` causes every resource
425
+
// to block the page load every time
426
+
w.Header().Set("Cache-Control", "max-age=60, stale-while-revalidate=3600")
427
+
// see https://web.dev/articles/stale-while-revalidate for details
428
+
}
427
429
428
430
// http.ServeContent handles conditional requests and range requests
429
431
http.ServeContent(w, r, entryPath, mtime, reader)