I think it would be really useful to have an option to disable caching entirely -- or just do it when debug is set to true -- as it can cause headaches when developing. I'm surprised this doesn't already exist.
Change cache driver to array
for the local
environment.
I know this isn't exactly what you want but it should work.
See above :thumbsup:
This should be added on documentation.
This does not seem to work in Laravel 5.2, I have solved this by setting ENV variable CACHE_EXPIRE to -1 which is then used to set how many minutes is cache valid, this stops caching globally.
@cerw It did work here. Same version. Make sure you have this on your .env file: CACHE_DRIVER=array
None of your solution work
@vietnguyen09 perhaps you've cached your configuration (caching the .env), changing the .env has no effect until you clear the cached configuration.
Proof - none of the solutions above worked:
CACHE_DRIVER=array
CACHE_EXPIRE=-1
and then
php artisan cache:clear
Laravel cache system is stupid - why the hell I can't disable caching simply turning it off? Or probably I must override BladeCompiler and set it as IoC - but why, these are all needless actions, please make it simple for us.
@vietnguyen09 @arthurkushman I got the reason, try to disable the OPcache of php. It's work for me.
@moonsn Thanks!!! It's work for me too.
@moonsn what about if i don't have access to php?
@engnaguib sorry, i don't know. did you sure that your Opcache of php status is enable?
@moonsn i think it's enable because the laravel cache working
We wanted this as well and tried the 'extend' the cache facade and gave up (I wish I could have that afternoon back) and ended up creating our own class (OurCache::) that calls Cache:: and adding our additional logic there. However and packages that use Cache::* (for example Entrust), you're screwed. Also, Laravel Cache has little or no opportunity for injection and not to mention, Facades suck. If anyone had tips on escaping the tyranny of facades, please let up know.
If anyone had tips on escaping the tyranny of facades, please let up know.
The real problem here is that Library/Packages use them .. as well as global helper functions; isn't?
IMO libs/packages should never do this but here we are.
100% agree.
this works in Laravel 5.x
:
.env
, set CACHE_DRIVER=none
'stores'
in app\config\cache.php
'none' => [
'driver' => 'null',
],
app\Providers\AppServiceProvider.php
use Illuminate\Cache\NullStore;
use Cache;
boot()
function in app\Providers\AppServiceProvider.php
Cache::extend( 'none', function( $app ) {
return Cache::repository( new NullStore );
} );
config:cache
, depending on your setup@mrextreme's solution does not work for me in Laravel 5.8 ...
Seriously, there is no way to disable view caching in the dev environment ?
Changing the cache driver to array
does not disable caching, and for instance if you change custom Blade directives, your templates are not updated and thus you have to _manually clear the view cache_. This is not a solution and this is really annoying.
@mrextreme's solution works fine for me on 5.8, except there is no need to add anything to a service provider - configuration only is enough. And that was enough even on 5.7.21. However this relates to cache facade. Blade caching is completely different.
@engnaguib sorry, i don't know. did you sure that your Opcache of php status is enable?
@moonsn Worked for me too ! Thanks
@mrextreme . I have same issue, i done your suggest, but it is not work in Laravel 5.8. Please help me if you can. thanks
Use this package, It will tackle all cache and clean it properly.
The only thing that worked for me on Laravel 5.4 was to manually delete the cached views from the storage folder:
sudo rm -f storage/framework/views/*
So here is the problem that alludes most of us, the fact is; there are SIX caches in Laravel
_Change
cache
driver toarray
for thelocal
environment._
^ This suggestion only effects 1 item (.1 The Data Cache
) out of the 6 caches.
- Configuration Files:
/config/cache.php
,.env
- Env/Default:
CACHE_DRIVER = 'file'
- Config Key:
config.cache.stores[CACHE_DRIVER]
#### Cache Location (Drivers):
/storage/framework/cache
as configured in config.cache.stores.file
Driver: Other > As configured in config.cache.stores.*
Cache::class
: add
, sear
, put
, set
, putMany
, putManyForever
, forever
, remember
, rememberForever
Cache::class
: forget
, delete
, deleteMultiple
, clear
(store->flush)php artisan cache:clear
(store->flush)
- Configuration Files:
/config/view.php
,.env
- Env/Default:
VIEW_COMPILED_PATH= 'realpath(storage_path('framework/views'))'
- Config Key:
config.view.compiled
#### Cache Location:
/storage/framework/views
php artisan view:cache
php artisan view:clear
- Configuration Files:
.env
- Env/Default:
APP_CONFIG_CACHE= 'cache/config.php'
#### Cache Location:
/bootstrap/cache/config.php
php artisan config:cache
php artisan config:clear
- Configuration Files:
.env
- Env/Default:
APP_ROUTES_CACHE= 'cache/routes-v7.php'
#### Cache Location:
/bootstrap/cache/routes-v7.php
php artisan route:cache
php artisan route:clear
- Configuration Files:
.env
- Env/Default:
APP_EVENTS_CACHE= 'cache/events.php'
#### Cache Location:
/bootstrap/cache/events.php
php artisan event:cache
php artisan event:clear
- Configuration Files:
.env
- Env/Default:
APP_SERVICES_CACHE = 'cache/services.php'
APP_PACKAGES_CACHE = 'cache/packages.php'
#### Cache Locations:
/bootstrap/cache/services.php
/bootstrap/cache/packages.php
composer du
composer du
php artisan clear-compiled
Command
optimize:clear
will run commands numbered above 1,2,3,4,6 not 5
php artisan optimize:clear
php artisan event:clear
Command
optimize
will run commands numbered above 3,4 not 2,5 and 1,6 is cache on demand only.
php artisan optimize
php artisan event:cache
php artisan view:cache
(Intensive, a view is cached on demand anyway)
A setting to disable caching of all of the above would be vastly appreciated!
Most helpful comment
Change cache driver to
array
for thelocal
environment.I know this isn't exactly what you want but it should work.