From 9386715e923249ac227acdf7c9ce2162b2c5d3b2 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Mon, 5 Feb 2024 10:21:52 +0300 Subject: [PATCH] Cache assets --- hosts/cube/site.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hosts/cube/site.nix b/hosts/cube/site.nix index 18a2659..ffa6afc 100644 --- a/hosts/cube/site.nix +++ b/hosts/cube/site.nix @@ -4,13 +4,21 @@ let inherit (config.networking) domain; port = 8003; + + cacheConfig = '' + add_header Cache-Control "public, max-age=10800, immutable"; + ''; in serverSystemConfiguration { services.site = enabled { inherit port; }; services.nginx.virtualHosts.${domain} = (sslTemplate domain) // { - locations."/".proxyPass = "http://[::]:${toString port}"; + locations."/".proxyPass = "http://[::]:${toString port}"; + locations."/assets" = { + proxyPass = "http://[::]:${toString port}/assets"; + extraConfig = cacheConfig; + }; }; services.nginx.virtualHosts."www.${domain}" = (sslTemplate domain) // { @@ -20,7 +28,10 @@ in serverSystemConfiguration { }; services.nginx.virtualHosts._ = (sslTemplate domain) // { - locations."/".proxyPass = "http://[::]:${toString port}/404/"; - locations."/assets".proxyPass = "http://[::]:${toString port}/assets"; + locations."/".proxyPass = "http://[::]:${toString port}/404/"; + locations."/assets" = { + proxyPass = "http://[::]:${toString port}/assets"; + extraConfig = cacheConfig; + }; }; }