Laravel 11 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 11 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 11.
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 11?
- 1) Application Cache Clear in Laravel 11
- 2) Route Cache Clear in Laravel 11
- 3) View Cache Clear in Laravel 11
- 4) Config Cache Clear in Laravel 11
- 5) Event Cache Clear in Laravel 11
- 6) All Cache Clear in Laravel 11
- 7) Cache Clear by Route in Laravel 11
1) Application Cache Clear in Laravel 11
This command will clean all application cache clear
Clear Cache:
php artisan cache:clear
2) Route Cache Clear in Laravel 11
This command will help to clear cache of routes.
Clear Route Cache:
php artisan route:clear
3) View Cache Clear in Laravel 11
This command will help to clear cache of views/blade files.
Clear View Cache:
php artisan view:clear
4) Config Cache Clear in Laravel 11
This command will help to clear cache of config.
Clear Config Cache:
php artisan config:clear
5) Event Cache Clear in Laravel 11
This command will help to clear cache of events.
Clear Event Cache:
php artisan event:clear
6) All Cache Clear in Laravel 11
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 11
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 11 Guzzle HTTP Request Example
- Laravel 11 Change Date Format Examples
- Laravel 11 Yajra Datatables Example Tutorial
- Laravel 11 REST API Authentication using Sanctum Tutorial
- Laravel 11 Markdown | Laravel 11 Send Email using Markdown Mailables
- Laravel 11 Ajax Form Validation Example Tutorial
- Laravel 11 Ajax Image Upload Example
- Laravel 11 Authentication using Jetstream Tutorial
- Laravel 11 Authentication - Install Laravel 11 Breeze Tutorial
- How to Send Email using Gmail in Laravel 11?
- Laravel 11 Import Export Excel and CSV File Tutorial
- Laravel 11 Generate PDF File using DomPDF Example
- Laravel 11 Multiple Image Upload Tutorial Example
- Laravel 11 CRUD Application Example Tutorial