server 配置:
server {
listen 80;
server_name insist.com www.insist.com;
root /var/www/insist.com;
index index index.html index.htm index.nginx-debian.html;
location = /django {
return 302 /django/;
}
location /django/ {
proxy_pass http://127.0.0.1:8000/;
proxy_redirect / /django/;
set $expire_time "20s";
if ($upstream_status = 301){ set $expire_time "40s"; }
expires $expire_time;
}
搜索了几个小时没找到完美解决方案,请各位帮忙看一看多谢了,多谢了!
1
xuexb 2022-03-17 14:24:23 +08:00
我也遇到这个问题了,使用以下方向解决:
```nginx # 30x 重定向不缓存 error_page 301 302 307 = @redirect_nocache; location @redirect_nocache { add_header Cache-Control 'no-store'; return 302 $upstream_http_location; } location @nodejs { proxy_pass http://nodejs$request_uri; proxy_intercept_errors on; # 重要 ... # 后台页页不加缓存 if ($uri !~* ^/admin/) { add_header Cache-Control 'max-age=600, s-maxage=604800'; } if ($uri ~* ^/admin(/|/.*)?$) { add_header Cache-Control 'no-store'; } } ``` |