Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.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
Php 如何删除特定页面的缓存_Php_Laravel_Caching_Browser - Fatal编程技术网

Php 如何删除特定页面的缓存

Php 如何删除特定页面的缓存,php,laravel,caching,browser,Php,Laravel,Caching,Browser,在laravel中使用sentry实现身份验证并注销时,如果我按“返回一页” 按钮返回到仪表板。如果页面被刷新,它将根据需要转到登录页面。但我想防止在不刷新的情况下访问仪表板 如何在注销后立即删除此特定页面的缓存 如何找到任何浏览器特定的页面缓存以及Laravel的方法 N.B.以这种方式注销并转到仪表板后,可防止根据需要更改任何内容。调用注销功能时破坏会话。只需在控制器中编写注销函数,如下所示: public function getLogout() { Sentry::log

在laravel中使用sentry实现身份验证并注销时,如果我按“返回一页” 按钮返回到仪表板。如果页面被刷新,它将根据需要转到登录页面。但我想防止在不刷新的情况下访问仪表板

  • 如何在注销后立即删除此特定页面的缓存
  • 如何找到任何浏览器特定的页面缓存以及Laravel的方法

  • N.B.以这种方式注销并转到仪表板后,可防止根据需要更改任何内容。

    调用注销功能时破坏会话。只需在控制器中编写注销函数,如下所示:

    public function getLogout() {
            Sentry::logout();
            Session::flush(); // Insert this line, it will  remove  all the session data
            return Redirect::to('users/login')->with('message', 'Your are now logged out!');
        }
    
    public function __construct() {
            $this->beforeFilter('csrf',array('on' => 'post'));
            $this->afterFilter("no-cache", ["only"=>"getDashboard"]);
        }
    
    编辑:

    首先,我只使用了Session:flush(),但不知怎的,它成功了!但当我再次检查时,我发现它不起作用。因此,我们需要添加一些代码,以便在注销时清除浏览器缓存

    使用过滤器可以解决此问题。(我还没有找到任何其他解决方案)首先,在filters.php中添加以下代码:

    Route::filter('no-cache',function($route, $request, $response){
    
        $response->header("Cache-Control","no-cache,no-store, must-revalidate");
        $response->header("Pragma", "no-cache"); //HTTP 1.0
        $response->header("Expires"," Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    
    });
    
    然后将此筛选器连接到路由或控制器。我将其附加到控制器的构造函数中,如下所示:

    public function getLogout() {
            Sentry::logout();
            Session::flush(); // Insert this line, it will  remove  all the session data
            return Redirect::to('users/login')->with('message', 'Your are now logged out!');
        }
    
    public function __construct() {
            $this->beforeFilter('csrf',array('on' => 'post'));
            $this->afterFilter("no-cache", ["only"=>"getDashboard"]);
        }