vendredi 3 juin 2016

How To clear cache after logout In Laravel

Its a common problem . When I logout and then click on the browser back button the browser shows the last loaded page from the website .

I have went through lots of links on stack most of them suggest to clear the headers on logout but it didn't worked .

here is the code that I have tried

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('/');
}); 

Update

I also tried to add this in my APP.blade.php file in the header

<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" />

If any of you have any IDEA please let me know

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire