Google chrome 在Laravel中注销后如何清除缓存
这是一个常见的问题。当我注销并单击浏览器后退按钮时,浏览器将显示网站上最后加载的页面 我已经浏览了堆栈上的很多链接,其中大多数都建议在注销时清除标题,但都不起作用 这是我尝试过的代码Google chrome 在Laravel中注销后如何清除缓存,google-chrome,caching,laravel-5,Google Chrome,Caching,Laravel 5,这是一个常见的问题。当我注销并单击浏览器后退按钮时,浏览器将显示网站上最后加载的页面 我已经浏览了堆栈上的很多链接,其中大多数都建议在注销时清除标题,但都不起作用 这是我尝试过的代码 Route::get('main/logout',function(){ Session::flush(); Auth::logout(); header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header
Route::get('main/logout',function(){
Session::flush();
Auth::logout();
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
session()->flash('alert-success', 'Success logged out');
return Redirect::to('/');
});
更新
我还尝试将其添加到标题中的APP.blade.php文件中
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="cache-control" content="must-revalidate" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
如果你们有什么想法,请告诉我
谢谢您必须在用户返回的页面上包括以下行,而不是实际的注销页面:
header("Cache-Control: no-cache, no-store, must-revalidate");
但这样做会失去浏览器缓存的优势,在大多数情况下,这不是一件好事。别管它了。用户在注销后仍然无法与服务器交互,只能检索他已经看到的数据。试试这个
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: text/html');
在注销函数中清除缓存,将此代码放在那里
Artisan::call('cache:clear');