How do I disable Laravel view cache? How do I disable Laravel view cache? laravel laravel

How do I disable Laravel view cache?


Out of the box? You can't. But you can extend the BladeCompiler class, overriding the method resposible for checking if the view has been expired:

class MyBladeCompiler extends BladeCompiler {    public function isExpired($path)    {        if ( ! \Config::get('view.cache'))        {            return true;        }        return parent::isExpired($path);    }}

You'll need to replace the BladeCompiler instance in IoC container, with your own compiler:

$app = App::make('app'); // or just $app = app();$app->bindShared('blade.compiler', function($app){    $cache = $app['path.storage'].'/views';    return new MyBladeCompiler($app['files'], $cache);});

And then you just need to create that key in your app/config/view.php file

<?phpreturn [    'cache' => false,    'paths' => [base_path().'/resources/views'],    'pagination' => 'pagination::slider-3',];

Or, like I do here:

return [    'cache' => in_array(App::environment(), ['production', 'staging']),];


this worked for me... added this to the .env file

CACHE_EXPIRE=-1


Solution

open php.ini

opcache.revalidate_freq=0opcache.fast_shutdown=0

change to this. restart apache.