diff --git a/nginx.conf b/nginx.conf index 76aa277..6c9ffa8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -26,7 +26,14 @@ server { add_header Cache-Control "no-store"; } - # 一图流图片目录,由 Docker 挂载提供,支持运行时新增图片 + # 一图流图片文件缓存 30 天;新增图片建议使用新文件名,避免同名覆盖缓存未刷新 + location ~* ^/learning-images/.+\.(png|jpg|jpeg|webp|gif|avif)$ { + root /usr/share/nginx/html; + expires 30d; + add_header Cache-Control "public, max-age=2592000"; + } + + # 一图流图片目录,由 Docker 挂载提供;目录列表不缓存,保证新增图片能及时被页面发现 location /learning-images/ { alias /usr/share/nginx/html/learning-images/; autoindex on;