How to Clear Cache In Laravel 10

How to Clear Cache In Laravel 10

In this post we will give you information about How to Clear Cache In Laravel 10. Hear we will give you detail about How to Clear Cache In Laravel 10 And how to use it also give you demo for it if it is necessary.

In this tutorial, We are going to learn how to clear route cache, laravel application cache, config cache, view cache and reoptimize class in a Laravel 10 application.

In Laravel, while developing a laravel application it is very often that changes we made are not reflected. This is usually happening because of the laravel cache. Laravel provides various caching systems for developing fast-loading laravel applications.

We will also learn how to remove cache in laravel with artisan command.

1. Laravel Cache Clear using Commands Line

  • Laravel Clear Route Cache
  • Laravel Clear App Cache
  • Laravel Clear Config Cache
  • Laravel Clear View Cache
  • Laravel Clear Cache using Reoptimized Class

Clear Route Cache

Use the below command and clear your routes cache:

php artisan route:cache

Also see: Laravel 10 Import Export Excel & CSV File Example

Clear Application Cache

Use the below command and clear your application cache like session cache, cookies cache:

php artisan cache:clear

Clear Config Cache

Use the below command and clear your config cache:

php artisan config:clear

Clear View Cache

Use the below command and clear your view (blade) cache:

php artisan view:clear

Also see: Upload Files and Images with Validation in Laravel

Clear Cache using Reoptimized Class

php artisan optimize:clear

2. Laravel Cache Clear using Artisan Command

In shared hosting servers typically we don’t have SSH access to the server. In that case, to clear Laravel cache we have to define routes in our application’s routes/web.php file that invoke the various Laravel clear cache commands. This way we can clear the Laravel cache by accessing specific routes in the browser.

 //Clear route cache
 Route::get('/route-cache', function() {
     Artisan::call('route:cache');
     return 'Routes cache cleared';
 });

 //Clear config cache
 Route::get('/config-cache', function() {
     Artisan::call('config:cache');
     return 'Config cache cleared';
 }); 

 // Clear application cache
 Route::get('/clear-cache', function() {
     Artisan::call('cache:clear');
     return 'Application cache cleared';
 });

 // Clear view cache
 Route::get('/view-clear', function() {
     Artisan::call('view:clear');
     return 'View cache cleared';
 });

 // Clear cache using reoptimized class
 Route::get('/optimize-clear', function() {
     Artisan::call('optimize:clear');
     return 'View cache cleared';
 });

Thank you for reading this blog.

Also see: How to Install Git On Ubuntu 20.04

  .       .

If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.

Hope this code and post will helped you for implement How to Clear Cache In Laravel 10. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US