1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-28 18:47:44 +00:00

nginx: cache headers for site

This commit is contained in:
RGBCube 2025-06-03 06:23:57 +03:00
parent 9904b03908
commit 4b9209bc97
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -7,11 +7,25 @@ in {
imports = [(self + /modules/nginx.nix)];
services.nginx = enabled {
appendHttpConfig = /* nginx */ ''
# Cache only successful responses.
map $status $cache_header {
200 "public";
302 "public";
default "no-cache";
}
'';
virtualHosts.${domain} = merge config.services.nginx.sslTemplate {
inherit root;
locations."/".tryFiles = "$uri $uri.html $uri/index.html =404";
locations."~ ^/assets/(fonts|icons|images)/".extraConfig = /* nginx */ ''
expires max;
add_header Cache-Control $cache_header always;
'';
extraConfig = /* nginx */ ''
error_page 404 /404.html;
'';