Laravel 12 Clear Cache of Route, View, Config, Event Commands

By Hardik Savani March 20, 2025 Category : Laravel

In this short article, I will show you how to clear cache of routes, views, config, and events in a Laravel 12 application.

Sometimes we need to clear the cache when changes are made in a configuration file or in the view file after a long time. So, the below command will help you to clear cache in Laravel 12.

I want to share my experience and solution. When I was working on my Laravel e-commerce website with GitLab, I encountered an issue where my view cache showed an error during development. I tried various methods to refresh it, but I couldn't see any changes in my view. Eventually, I resolved my problem using Laravel commands. So, let's see, I've added several commands to clear the cache from views, routes, configurations, etc.

Step for How to Cache Clear of Routes, Views, Config and Events in Laravel 12?

  • 1) Application Cache Clear in Laravel 12
  • 2) Route Cache Clear in Laravel 12
  • 3) View Cache Clear in Laravel 12
  • 4) Config Cache Clear in Laravel 12
  • 5) Event Cache Clear in Laravel 12
  • 6) All Cache Clear in Laravel 12
  • 7) Cache Clear by Route in Laravel 12

1) Application Cache Clear in Laravel 12

This command will clean all application cache clear

Clear Cache:

php artisan cache:clear

2) Route Cache Clear in Laravel 12

This command will help to clear cache of routes.

Clear Route Cache:

php artisan route:clear

3) View Cache Clear in Laravel 12

This command will help to clear cache of views/blade files.

Clear View Cache:

php artisan view:clear

4) Config Cache Clear in Laravel 12

This command will help to clear cache of config.

Clear Config Cache:

php artisan config:clear

5) Event Cache Clear in Laravel 12

This command will help to clear cache of events.

Clear Event Cache:

php artisan event:clear

6) All Cache Clear in Laravel 12

This command will help to clear cache of config, views, cache files etc.

Command:

php artisan optimize:clear

7) Cache Clear by Route in Laravel 12

You can also clear cache without command using route. so you can create route as like bellow:

Route::get('/clear-cache-all', function() {

    Artisan::call('cache:clear');
  
    dd("Cache Clear All");
});

I hope it can help you...

Shares