Laravel 5 Clear Views Cache

Laravel 5 Clear Views Cache

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Managing Laravel View Caches and Storage

In a long-running Laravel application, storage/framework/views can easily become a significant drain on disk space. As you iterate through views, Laravel compiles them into PHP classes and stores these compiled files in that directory. While this compilation speeds up rendering by bypassing the Blade parser, it also means that every time you change a view file or run certain migrations, those cached versions become stale.

The most common frustration arises when developers attempt to clear this specific cache using php artisan cache:clear. It is important to understand why this command fails to solve the problem. The cache:clear command targets the application's key-value store (typically files in storage/framework/cache, Redis, or Memcached), not the compiled view classes. In Laravel 5 and earlier versions, there was no single artisan command dedicated solely to clearing the views cache because the framework did not distinguish between the two storage mechanisms in its CLI interface.

To reclaim the space occupied by stale view files, you must manually remove the contents of the storage/framework/views directory. You can do this safely via the command line:

rm -rf storage/framework/views/*

While deleting the folder entirely is also an option, removing only the files ensures that the .gitignore configuration for the storage directory remains intact, preventing accidental commits of sensitive or large compiled assets. After deletion, Laravel will automatically regenerate these files on demand when a view is rendered next. This on-demand regeneration adds a negligible amount of overhead to page loads but ensures your application always uses the most up-to-date compiled views.

If you are deploying to a production environment, it is best practice to include a script in your deployment process that clears this directory after pulling down new code. Since view changes often happen alongside feature updates or layout tweaks, failing to clear the cache can lead to "stale view" bugs where the backend logic has changed, but the browser still renders the old HTML because the compiled PHP class hasn't been updated.

For teams that find manual deletion cumbersome or want to prevent storage bloat entirely, you might consider disabling view compilation altogether. This is particularly relevant if your team prefers to keep views as raw Blade templates without the performance benefit of pre-compilation. To disable this feature, add the following line to your config/view.php configuration file:

'compiled' => false,

When set to false, Laravel will render views directly from the template files every time they are requested. This eliminates the need to manage the views directory and ensures that any changes to a .blade.php file are immediately reflected without intervention. The trade-off here is a slight increase in CPU usage during rendering, as the Blade parser must run on every request. For high-traffic applications where millisecond latency matters, keeping compilation enabled is usually preferable. However, for development environments or low-traffic sites, disabling it can reduce operational friction and simplify deployment pipelines.

If you require further assistance with Laravel 5 configuration or need to optimize your application's storage layout, resources like https://laravelcompany.com offer detailed guides on maintaining stable deployments.

Our network