Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Cached Routes not updating

I've cached my Laravel 5 routes by doing php artisan route:cache. This went succesfull for quite a while and when I changed a route is could cache them again and it would all work like it should.

The problem is that I've moved some routes to another route group and it seems that they won't be cached for some reason.

I've tried to cache them again but it didn't work. I've also tried php artisan cache:clear but still not working.

Routes.php changes:

Route::group(['prefix' => 'api', 'middleware' => 'auth'], function () {
   Route::get('invites', 'InvitationController@get');
   Route::get('invites/check', 'InvitationController@check');
});

Changed to:

Route::group(['prefix' => 'api'], function () {
   Route::post('auth', 'Auth\AuthController@authenticate');
   Route::get('invites', 'InvitationController@get');
   Route::get('invites/check', 'InvitationController@check');
});

As you can see I've moved those invitation routes to the Route group without the Authenticate Middleware. When I cached the routes again, it still does execute the Auth Middleware even when they are moved out of the group..

like image 849
guidsen Avatar asked Mar 28 '15 18:03

guidsen


People also ask

How do I clear a cache route?

Clearing Route Cache The following command will clear all route cache in your application: $ php artisan route:clear Route cache cleared! To cache your routes again, simply run the following command: $ php artisan route:cache Route cache cleared!

Which command is used to reset the cache in Laravel?

In laravel application you can clear cache two types using artisan command and from browsers.

Where does Laravel store cached data?

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.


2 Answers

The right syntaxe to remove cached route in laravel 5.* is

php artisan route:clear

Regards

like image 141
Goopil Avatar answered Oct 20 '22 23:10

Goopil


If you don't want to optimize again with every change. You can try this;

CACHE_DRIVER=file to change => CACHE_DRIVER=array

After, you should clear to folder "bootstrap/cache"

I hope it works.

like image 21
irfanyy Avatar answered Oct 20 '22 22:10

irfanyy