簡體   English   中英

從我的應用程序注銷后,如果按返回按鈕,我可以看到上一頁

[英]After Log out from my app, if i press back button, i can see the previous page

我已將無緩存代碼嵌入到application_controller中。 但是,它僅在某些情況下有效。 還有其他解決方案嗎? Facebook和Gmail如何解決此問題。 提前致謝!

請求任何頁面時,瀏覽器將緩存頁面。 您需要防止瀏覽器緩存。 因此,您可以這樣做。

在您的application_controller中:

before_filter :set_cache_buster
def set_cache_buster
  response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
  response.headers["Pragma"] = "no-cache"
  response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end

所有功勞歸功於此網址http://blog.serendeputy.com/posts/how-to-prevent-browsers-from-caching-a-page-in-rails/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM