ML Intern deploy commited on
Commit
edb5ea4
·
1 Parent(s): 6917738

perf: enable gzip + immutable cache headers for SPA assets (6MB initial payload -> ~2MB, repeat visits ~0KB)

Browse files
Files changed (1) hide show
  1. nginx.hf.conf +30 -0
nginx.hf.conf CHANGED
@@ -22,6 +22,14 @@ http {
22
  keepalive_timeout 65;
23
  server_tokens off;
24
 
 
 
 
 
 
 
 
 
25
  upstream httpsms_api {
26
  server 127.0.0.1:8000;
27
  }
@@ -50,6 +58,28 @@ http {
50
  alias /usr/share/nginx/html/HttpSms.apk;
51
  default_type application/vnd.android.package-archive;
52
  add_header Content-Disposition 'attachment; filename="HttpSms.apk"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  # Nuxt static SPA with client-side routing fallback
 
22
  keepalive_timeout 65;
23
  server_tokens off;
24
 
25
+ # Compression: cuts the SPA payload by ~65-75%
26
+ gzip on;
27
+ gzip_vary on;
28
+ gzip_min_length 1024;
29
+ gzip_comp_level 5;
30
+ gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml;
31
+ gzip_proxied any;
32
+
33
  upstream httpsms_api {
34
  server 127.0.0.1:8000;
35
  }
 
58
  alias /usr/share/nginx/html/HttpSms.apk;
59
  default_type application/vnd.android.package-archive;
60
  add_header Content-Disposition 'attachment; filename="HttpSms.apk"';
61
+ add_header Cache-Control "public, max-age=3600";
62
+ }
63
+
64
+ # Hashed Nuxt build assets: content-addressed, cache forever
65
+ location ^~ /_nuxt/ {
66
+ root /usr/share/nginx/html;
67
+ try_files $uri =404;
68
+ add_header Cache-Control "public, max-age=31536000, immutable";
69
+ }
70
+
71
+ # Other static assets: public short cache
72
+ location ~* \.(?:css|js|svg|png|jpg|jpeg|gif|webp|ico|woff2?|ttf|eot|xlsx|csv)$ {
73
+ root /usr/share/nginx/html;
74
+ try_files $uri =404;
75
+ add_header Cache-Control "public, max-age=2592000";
76
+ }
77
+
78
+ # HTML: always revalidate so new builds propagate
79
+ location ~* \.html$ {
80
+ root /usr/share/nginx/html;
81
+ try_files $uri =404;
82
+ add_header Cache-Control "no-cache";
83
  }
84
 
85
  # Nuxt static SPA with client-side routing fallback