Ruby on rails 如何将_重定向到Rails中新呈现的页面(未缓存)?
在Rails 3(使用Chrome)中,我设置了一个flash,调用redirect_to,然后将浏览器发送回用户以前访问过的页面 但是,Chrome不会呈现此页面;相反,Chrome从缓存中获取它。例如,这意味着不渲染闪光灯 我可以向URL添加一个随机参数,以确保不使用缓存,但这很笨拙Ruby on rails 如何将_重定向到Rails中新呈现的页面(未缓存)?,ruby-on-rails,ruby-on-rails-3,caching,redirect,Ruby On Rails,Ruby On Rails 3,Caching,Redirect,在Rails 3(使用Chrome)中,我设置了一个flash,调用redirect_to,然后将浏览器发送回用户以前访问过的页面 但是,Chrome不会呈现此页面;相反,Chrome从缓存中获取它。例如,这意味着不渲染闪光灯 我可以向URL添加一个随机参数,以确保不使用缓存,但这很笨拙 如何确保重定向到的页面被重新呈现?有几种方法可以做到这一点:meta-http-equiv标记或http头 方法A)元http等价 将以下内容添加到模板的标题部分 <% if @prevent_cachi
如何确保重定向到的页面被重新呈现?有几种方法可以做到这一点:
meta-http-equiv
标记或http头
方法A)元http等价
将以下内容添加到模板的标题部分
<% if @prevent_caching %>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<% end %>
然后,与之前一样,只是调用了方法而不是设置变量
#in the controller where you don't want the response to be cached
prevent_browser_caching
#in the controller where you don't want the response to be cached
prevent_browser_caching