From 3399e17dd1d5bfa402f16b029ada72febbca2ea1 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa <jelle@archlinux.org> Date: Sat, 19 Feb 2022 11:54:09 +0100 Subject: [PATCH] aurweb: serve assets from nginx and cache properly Make nginx serve static assets to offload gunicorn as for example loading the home page is making 7 static requests out of 8 requests in total. Set caching headers for now for 7 days, so browsers don't request ideally this would be 30 days but let's keep it 7 days for now. --- roles/aurweb/templates/nginx.d.conf.j2 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/aurweb/templates/nginx.d.conf.j2 b/roles/aurweb/templates/nginx.d.conf.j2 index f89bf618d..06234d165 100644 --- a/roles/aurweb/templates/nginx.d.conf.j2 +++ b/roles/aurweb/templates/nginx.d.conf.j2 @@ -71,6 +71,14 @@ server { expires 5m; } + location ~ ^/static/(?:css|js|images)/ { + rewrite ^/static(/.*)$ $1 break; + + expires 7d; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + location / { # Proxy over to aurweb's ASGI application. proxy_pass http://{{ aurweb_asgi_bind }}; -- GitLab