小编Kév*_*lin的帖子

nginx反向代理禁用缓存

我使用 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;
}
Run Code Online (Sandbox Code Playgroud)

我尝试在没有 nginx 的情况下进行查询,并且在控制台中一切正常

谢谢你!

nginx no-cache nginx-reverse-proxy

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

nginx ×1

nginx-reverse-proxy ×1

no-cache ×1