Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何将_重定向到Rails中新呈现的页面(未缓存)?_Ruby On Rails_Ruby On Rails 3_Caching_Redirect - Fatal编程技术网

Ruby on rails 如何将_重定向到Rails中新呈现的页面(未缓存)?

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

在Rails 3(使用Chrome)中,我设置了一个flash,调用redirect_to,然后将浏览器发送回用户以前访问过的页面

但是,Chrome不会呈现此页面;相反,Chrome从缓存中获取它。例如,这意味着不渲染闪光灯

我可以向URL添加一个随机参数,以确保不使用缓存,但这很笨拙


如何确保重定向到的页面被重新呈现?

有几种方法可以做到这一点:
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