Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some sort of Laravel Controller cache?

Weird problem I'm having with Laravel 5.5

I can update and even delete a controller and yet it appears as if a cached / old version is still being called.

I've tried clearing cache, clearing route cache, clearing config cache - doesn't seem to have any effect.

On my local test environment if I delete the controller file then try to access it I immediately get a not found error. On my production server I do not.

Anyone have any ideas or advice?

like image 911
jeremyj11 Avatar asked Dec 20 '17 10:12

jeremyj11


People also ask

Does Laravel have caching?

Laravel supports popular caching backends like Memcached, Redis, DynamoDB, and relational databases out of the box. In addition, a file based cache driver is available, while array and "null" cache drivers provide convenient cache backends for your automated tests.

Does Laravel view cache?

When a request is executed that renders a view, Laravel will compile the view if a pre-compiled view does not already exist (or if the view has been modified more recently than the compiled view). View caching pre-compiles all of the views utilized by your application.

Where cache is stored Laravel?

Laravel provides a unified API for various caching systems. The cache configuration is located at app/config/cache. php . In this file you may specify which cache driver you would like used by default throughout your application.

How does Laravel cache work?

Laravel creates an encrypted file with the data and the cache key when new data is cached. The same happens when the user is trying to retrieve the content. Laravel cache searches through the folder for the specified key and, if found, returns the content.


2 Answers

I had the same problem. As for me, the reason was in composer classLoader.

composer clear-cache
composer dump-autoload
like image 42
Den Avatar answered Sep 22 '22 20:09

Den


You can try running:

php artisan clear-compiled

and

composer dump-autoload

and

php artisan route:cache

and if you are running queues:

php artisan queue:restart

Also be aware the errors you are getting might be different depending on APP_ENV or APP_DEBUG in your .env file but maybe that's not the case.

like image 173
Marcin Nabiałek Avatar answered Sep 24 '22 20:09

Marcin Nabiałek