diff --git a/crates/ptth_server/src/file_server.rs b/crates/ptth_server/src/file_server.rs index 6b98539..f279ae2 100644 --- a/crates/ptth_server/src/file_server.rs +++ b/crates/ptth_server/src/file_server.rs @@ -198,11 +198,12 @@ async fn serve_file ( // - no-cache - Clients and the relay can store this, but should revalidate // with the origin server (us) because only we can check if the file // changed on disk. - // - max-age=0 - The file might change at any point during or after the - // request, so for proper invalidation, the client should immediately - // consider it stale. + // - max-age=5 - Caches can keep the file for 5 seconds. This is just enough + // to let a cache like Nginx or Varnish on a relay soak up some of a + // slashdotting for us, but not so much that a low-traffic site would + // suffer from seeing stale data. - response.header ("cache-control".to_string (), b"no-cache,max-age=0".to_vec ()); + response.header ("cache-control".to_string (), b"no-cache,max-age=5".to_vec ()); if let Some (etag) = input.actual_etag { response.header ("etag".to_string (), etag); }; @@ -246,6 +247,7 @@ fn serve_file_decision (input: &ServeFileInput) -> ServeFileOutput if let (Some (if_none_match), Some (actual_etag)) = (&input.if_none_match, &input.actual_etag) { if actual_etag == if_none_match { + info! ("Not Modified"); return ServeFileOutput { status_code: StatusCode::NotModified, should_send_body: false,