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:
parent
9904b03908
commit
4b9209bc97
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue