diff --git a/api/static-site.ts b/api/static-site.ts index 41ae6e3..160a4c5 100644 --- a/api/static-site.ts +++ b/api/static-site.ts @@ -306,7 +306,16 @@ const NGINX_CONF = `server { location / { # The build writes about/index.html, so a directory match is what serves /about. - try_files $uri $uri/ =404; + # + # $uri/index.html BEFORE $uri/, and the order is the whole point. A $uri/ match is a directory + # and nginx answers it with a 301 that appends the slash — so /gallery/aldi/65 cost a redirect + # before anything on the page could start. Every internal link on this site is the bare form (the + # thumbnails, the lightbox, the chevrons), so every navigation paid it: 78 ms on the critical path, + # measured, on the first request of every page. + # + # Naming index.html first serves the file at the address that was asked for. Both forms still work + # and neither redirects; $uri/ stays after it for a directory that has no index. + try_files $uri $uri/index.html $uri/ =404; add_header Cache-Control "no-cache"; } }