From 8073ae6942de78148003e2111bda2e0dbb936eb4 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 31 Aug 2024 00:52:13 +0200 Subject: [PATCH] feat(s3-revproxy): tune the cache-control Adopt the original values from the Perl script. Signed-off-by: Raito Bezarius --- services/s3-revproxy/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/s3-revproxy/default.nix b/services/s3-revproxy/default.nix index b456fb1..cbc8345 100644 --- a/services/s3-revproxy/default.nix +++ b/services/s3-revproxy/default.nix @@ -122,6 +122,16 @@ in allowMethods = [ "GET" ]; allowOrigins = [ "*" ]; }; + + cache = { + noCacheEnabled = false; + # Taken from the original Perl script. + # maxage=600: Serve from cache for 5 minutes. + # stale-while-revaliadate=1800: Serve from cache while updating in the background for 30 minutes. + # https://web.dev/stale-while-revalidate/ + # https://developer.fastly.com/learning/concepts/cache-freshness/ + cacheControl = "maxage=600,stale-while-revalidate=1800,public"; + }; }; targets = mapAttrs (name: bucket: mkTarget { inherit name bucket; }) cfg.targets; };