Is there some sort of Laravel Controller cache?

13.1k Views Asked by At

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?

7

There are 7 best solutions below

4
Marcin Nabiałek On

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.

1
jeremyj11 On

Alright don't know what the problem was but deleting the 'Http' directory in 'App' and re ftping did the trick.

0
Den On

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

composer clear-cache
composer dump-autoload
0
Anibal E. Alvarez Sifontes On

I had the same problem once, because i had placed a "CustomController2" along with a "CustomController", just because i didn't want to the delete the previows one in case of failure.

I deleted the second one and cleared the route cache, and the problem was fixed.

0
jpussacq On

I had the same problem because of htaccess. I commented this line and problem solved:

ExpiresDefault "access 2 days"

Files were cached by browser:

## EXPIRES HEADER CACHING ##

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
##ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES HEADER CACHING ##
0
BlackPearl On

In my case, I did as suggested by the other solutions contributed here but nothing happened. I had to refresh the Wamp Server I was using and that was it, it started working fine again.

0
Mátyás Grőger On

For me I had the same mistake, tried everything but didnt help. Finally it turned out the browser was caching the get request which was sent. I tried clear application data by browser, but this did not help. Although looking the website in incognito mode, it was working as expected.

Finally I solved with by adding a timestamp to such get request where this caching happened.

 href="{{route('my-route').'?timestamp='.\Illuminate\Support\Carbon::now()->toDateTimeString()}}"