Laravel 12 Clear Cache of Route, View, Config, Event Commands
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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel 12 Get Client IP Address Example
- Laravel 12 Cron Job Task Scheduling Example
- Laravel 12 Guzzle HTTP Request Tutorial
- Laravel 12 Change Date Format Examples
- Laravel 12 Send Email using Queue Example
- Laravel 12 Multiple Image Upload Example
- Laravel 12 Multiple File Upload Example
- Laravel 12 Create, Run & Rollback Migration
- Laravel 12 Yajra Datatables Example Tutorial
- Laravel 12 Database Seeder Tutorial Example
- How to Create Custom Helper Functions in Laravel 12?
- Laravel 12 Import Export Excel and CSV File Example
- Laravel 12 Image Upload Example Tutorial
- Laravel 12 CRUD Application Example Tutorial