我使用nginx作为反向代理连接API。问题在于,当我添加或删除某些内容后发送查询时,Nginx会返回旧的JSON值。我尝试禁用缓存,但没有效果。
我的nginx配置:
location / {
sendfile off;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
proxy_no_cache 1;
proxy_cache_bypass 1;
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HTTPS $https;
}
我尝试了不使用nginx的查询,所有内容在控制台中都正常工作。
谢谢!