[mirror] Scalable static site server for Git forges (like GitHub Pages)
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow setting custom Cache-Control headers via _headers

Before this change Cache-Control header would always be overridden, this
change allows custom Cache-Control, provided Cache-Control is added to
the header allow list.

+9 -7
+9 -7
src/pages.go
··· 417 io.Copy(w, reader) 418 } 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 427 428 // http.ServeContent handles conditional requests and range requests 429 http.ServeContent(w, r, entryPath, mtime, reader)
··· 417 io.Copy(w, reader) 418 } 419 } else { 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 + } 429 430 // http.ServeContent handles conditional requests and range requests 431 http.ServeContent(w, r, entryPath, mtime, reader)