Laravel and View Caching in Development -- Can't See Changes Right Away

Laravel and view caching in development -- can't see changes right away

The #laravel IRC channel is a God send. This had nothing to do with Laravel's behavior at all. This was actually something PHP 5.5 was doing.

The reason this was so baffling is because I upgraded my PHP version from 5.3 and never had this issue.

In your .ini file, you need to tweak your OPcache settings. For me, these settings began at line 1087 in the .ini file and looked something like this:

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Take particular note of the opcache.revalidate_freq=60. This is what is actually making your views cache. If this is not the desired behavior, set the value to 0 and your views will update every time you make a change. Yay!

EDIT AUGUST 21, 2014

As mentioned by Matt below, make sure to restart your web server to see your changes take effect after you have changed your .ini file.

Laravel 5 view caching

If you don't have a shell access to run artisan commands you can create a dummy route to do that. (Feels like a dirty solution :) )

Route::get('/clearViews', function () {
Artisan::call('view:clear', []);
//
});

Blade view not reflecting changes

In order to avoid the parsing of Blade files on each reload, Laravel caches the views after Blade is processed. I've experienced some situations where the source (view file) is updated but the cache file is not "reloaded". In these cases, all you need to do is to delete the cached views and reload the page.

The cached view files are stored in storage/framework/views.

Getting frustrated with Laravel 5 blades

Are you sure it's not just cached? Try this: go to your \storage\framework\views and delete everything except .gitignore file, and try again.

If laravel is caching your view, clearing the browser cache won't help you as the caching is done server-side.

If you are actually using laravel 5.1, you can type on your terminal php artisan view:clear

More info: laravel.com/docs/5.0/cache

local Laravel web page takes several minutes to update

In case anyone else has the same problem, I fixed this by disabling caching in my php.ini file and restarting my server (see this post) why this became an issue out of the blue after several weeks, I have no idea.



Related Topics



Leave a reply



Submit