2015-11-05 113 views

回答

2

瀏覽器可以訪問頁面,因爲默認情況下允許緩存響應。如果要防止這種情況,你需要設置需要身份驗證的頁面相應的HTTP報頭,按this similar question

Cache-Control: no-cache, no-store, must-revalidate 
Pragma: no-cache 
Expires: 0 

你可以在一個插件

defmodule MyApp.PreventCaching do 
    import Plug.Conn 

    def init(options) do 
    options 
    end 

    def call(conn, _opts) do 
    conn 
    |> put_resp_header(conn, "cache-control", "no-cache, no-store, must-revalidate") 
    |> put_resp_header(conn, "pragma", "no-cache") 
    |> put_resp_header(conn, "expires", "0") 
    end 
end 

這樣做,那麼你路由器(或控制器),您可以使用插件來設置需要身份驗證的

plug MyApp.PreventCaching 
+0

感謝您的關注帕特里克Oscity所有頁面的頁眉,這是我的問題1回答如果任何人想阻止這一點,我會把我的代碼放在這裏 –

相關問題