placeholder for caching - Always returns a random ETag header.
So the browser-side cache will always miss, but I tested that Firefox will at least send us If-None-Match with the last ETag it saw.main
parent
6e24983ad7
commit
3389292457
|
@ -189,6 +189,21 @@ async fn serve_file (
|
||||||
|
|
||||||
let mut response = Response::default ();
|
let mut response = Response::default ();
|
||||||
|
|
||||||
|
// The cache-related headers in HTTP have bad names. See here:
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
||||||
|
// The intended semantics I'm using are:
|
||||||
|
// - etag - Some random hashed value that changes whenever the metadata
|
||||||
|
// (name, inode number, length, mtime) of a file changes. Also changes
|
||||||
|
// on new server instance.
|
||||||
|
// - 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.
|
||||||
|
|
||||||
|
response.header ("cache-control".to_string (), b"no-cache,max-age=0".to_vec ());
|
||||||
|
response.header ("etag".to_string (), rusty_ulid::generate_ulid_string ().into_bytes ());
|
||||||
response.header (String::from ("accept-ranges"), b"bytes".to_vec ());
|
response.header (String::from ("accept-ranges"), b"bytes".to_vec ());
|
||||||
|
|
||||||
if range_requested {
|
if range_requested {
|
||||||
|
|
Loading…
Reference in New Issue