my nixos config
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix the caching for the website

chfour 9260ce1c 13c8573b

+24 -3
+24 -3
machines/fovps/services/caddy/default.nix
··· 1 - { pkgs, website, ... }: 1 + { pkgs, config, website, ... }: 2 2 3 - { 3 + let 4 + lastModified = "${config.services.caddy.dataDir}/Last-Modified"; 5 + in { 4 6 services.caddy.enable = true; 5 7 services.caddy.extraConfig = '' 6 8 (errors) { ··· 27 29 redir * https://github.com/chfour/nixos/tree/main{uri} 28 30 } 29 31 30 - # the usual 32 + vars { 33 + # epic hack hacky hackk 34 + import ${lastModified} 35 + } 36 + 31 37 root * ${websitePath} 32 38 encode zstd gzip 39 + header { 40 + Last-Modified {vars.Last-Modified} 41 + defer 42 + } 33 43 file_server 34 44 ''; 35 45 ··· 42 52 browse ${./browsetemplate.html} 43 53 } 44 54 ''; 55 + }; 56 + 57 + systemd.services.caddy = { 58 + preStart = '' 59 + { 60 + echo -n 'Last-Modified "' 61 + date --date="@$(stat /usr/bin/env --format='%Y')" -Ru \ 62 + | sed 's/+0000$/GMT/' | tr -d '\n' 63 + echo '"' 64 + } > ${lastModified} 65 + ''; 45 66 }; 46 67 networking.firewall.allowedTCPPorts = [ 80 443 ]; 47 68 networking.firewall.allowedUDPPorts = [ 80 443 ];