8

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?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
jeremyj11
  • 589
  • 1
  • 5
  • 15

7 Answers7

4

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.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • @JeremyJacob Maybe stupid question - are you sure you deployed new code into live server? Try running also `php artisan route:cache` – Marcin Nabiałek Dec 20 '17 at 10:48
  • yes, tried the route:cache command, no change. This is crazy - I've now deleted the entire 'Controllers' directory and there is no change. I'm definitely accessing the right server, as renaming the 'public' directory causes a 404 not found error. – jeremyj11 Dec 20 '17 at 10:53
  • Is it possible you are using some other server like Cloudflare for example for caching? – Marcin Nabiałek Dec 20 '17 at 10:54
  • @JeremyJacob After deleting controller, what `php artisan route:list` shows? – Tpojka Dec 20 '17 at 12:24
2

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

composer clear-cache
composer dump-autoload
Den
  • 1,456
  • 16
  • 17
1

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()}}" 
Mátyás Grőger
  • 1,207
  • 2
  • 13
  • 24
0

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

jeremyj11
  • 589
  • 1
  • 5
  • 15
0

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

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 ##
jpussacq
  • 573
  • 9
  • 29
0

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.

BlackPearl
  • 2,532
  • 3
  • 33
  • 49