From 8003c07762931d77282f436109629b144925ffe7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 12 Jun 2020 18:06:55 -0700 Subject: [PATCH] modules/media: Add explicit cache controls w/ immutability hint. --- modules/media/download.cc | 11 ++++++++++- modules/media/thumbnail.cc | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/media/download.cc b/modules/media/download.cc index 69b6e96d5..3fff601ba 100644 --- a/modules/media/download.cc +++ b/modules/media/download.cc @@ -127,10 +127,19 @@ get__download_local(client &client, }; }); + static const auto &addl_headers + { + "Cache-Control: public, max-age=31536000, immutable\r\n"_sv + }; + // Send HTTP head to client m::resource::response { - client, http::OK, content_type, file_size + client, + http::OK, + content_type, + file_size, + addl_headers, }; size_t sent{0}, read diff --git a/modules/media/thumbnail.cc b/modules/media/thumbnail.cc index 4addacf53..be5f5b08e 100644 --- a/modules/media/thumbnail.cc +++ b/modules/media/thumbnail.cc @@ -327,10 +327,15 @@ get__thumbnail_local(client &client, "Unknown reason", }; + static const auto &addl_headers + { + "Cache-Control: public, max-age=31536000, immutable\r\n"_sv + }; + if(fallback) return m::resource::response { - client, buf, content_type + client, buf, content_type, http::OK, addl_headers }; const auto closure{[&client, &content_type] @@ -338,7 +343,7 @@ get__thumbnail_local(client &client, { m::resource::response { - client, buf, content_type + client, buf, content_type, http::OK, addl_headers }; }};