From 01a3efd40229e68ea0ea6978d8ee9abe45416c3a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 17 May 2024 13:58:29 +0800 Subject: [PATCH] fix nginx cache --- nginx.conf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index e40b2b9a..36a909e8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -34,10 +34,16 @@ http { try_files $uri $uri/ /index.html; } + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + # 静态资源 + expires 1y; + add_header Cache-Control "public, immutable"; + } + location /assets { # 静态资源 - expires 7d; - add_header Cache-Control "public"; + expires 1y; + add_header Cache-Control "public, immutable"; root /public; }