How to disable the Cache in Laravel

Sometimes its necessary to disable the caching in Laravel. To do so a new cache-driver “none” must be added to the cache-configuration-file in config/cache.php

'stores' => [
    //...
    'none' => [
        'driver' => 'null',
    ],
  ],

After that you have to set this cache-driver in your .env-File and you Cache is disabled

Edit .env and change the line
CACHE_DRIVER=file
to
CACHE_DRIVER=none

Clearing some Caches in Laravel

Clear Application Cache:

php artisan cache:clear

Clear Route Cache

Throws an error if CACHE_DRIVER=none

php artisan route:clear

Clear Configuration Cache

Throws an error if CACHE_DRIVER=none

php artisan config:clear 

 Clear Compiled Views Cache

Throws an error if CACHE_DRIVER=none

php artisan view:clear 

Leave a Reply

Your email address will not be published. Required fields are marked *