Redirect nginx清除客户端浏览器缓存中的永久301

Redirect nginx清除客户端浏览器缓存中的永久301,redirect,caching,nginx,browser-cache,http-status-code-301,Redirect,Caching,Nginx,Browser Cache,Http Status Code 301,对于Nginx中的一个特定重定向,我愚蠢地使用301而不是302 location /somewhere/ { return 301 /somewhere/neat/; } 但现在我也需要改变我们的方向: location /somewhere/ { # 302 now, lets not make the same mistake again! return 302 /somewhere/else/entirely/; } 当然,如果我在匿名模式下查看URL或破坏浏览器重定向缓

对于Nginx中的一个特定重定向,我愚蠢地使用301而不是302

location /somewhere/ {
  return 301 /somewhere/neat/;
}
但现在我也需要改变我们的方向:

location /somewhere/ {
  # 302 now, lets not make the same mistake again!
  return 302 /somewhere/else/entirely/;
}

当然,如果我在匿名模式下查看URL或破坏浏览器重定向缓存,我可以看到这种变化,但如果许多用户自己不这样做,就无法看到它。即使我们能够可靠地指示客户破坏他们的缓存,我们也只能访问其中的一小部分,其余的都将保留旧内容

你说的是缓存破坏,我也有同样的问题。您所需要做的就是(如果我理解正确的话)强制在url的末尾添加一个查询字符串参数,这将有效地强制客户端浏览器刷新以获取任何“新”内容

一种可能的修复方法是在url的末尾追加一个查询字符串(如果该查询字符串还不存在)

在您的情况下,您可能可以使用重写,既“修复”错误的url,又缓存破坏原始url重定向:

# Fix the incorrect url
location /somewhere/neat/ {
  rewrite ^(.*)$ /somewhere/$1?cb=12345 last;
}

# Handle the new redirect
location /somewhere/ {
  return 302 /somewhere/else/entirely/;
}
cb=12345可以是您想要的任何内容,只要它只是一个查询字符串


这种方法的唯一问题是,如果您的位置/某处/整洁仍然需要是一个活动页面,因为这将有效地迫使它始终返回到/某处

不是非常有经验的w/ngnix和ssl(因此不确定这个答案是否完全适用,但是)有同样的问题,我只需要清除浏览器上的缓存来修复缓存问题。(在我的案例中,我怀疑是因为当天早些时候测试了重定向(带旧站点)。