ItSolutionStuff.com

Laravel Clear Cache of Route, View, Config Command

By Hardik Savani • April 16, 2024
Laravel

Hello,

Here, I will show you laravel clear cache. This tutorial will give you a simple example of laravel clear cache config. you can understand a concept of laravel cache clear view. Here you will learn laravel cache clear config.

You can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 versions.

Sometimes we need to cache clear when you change in a configuration file or anything changes on the view file after a long time. so bellow command will help you to clear cache in laravel.

I want to share my experience and solution. when I was working on my laravel e-commerce website with GitLab. I was fetching one issue suddenly my view cache with an error during development. I did try a lot to refresh and something other but I can't see any more change in my view, but at last, I did resolve my problem using the laravel command so, let's see I added several commands for clear cache from view, route, config, etc.

Let's see the list of commands for clearing cache in laravel. I will give you command with output:

1) Application Cache Clear in Laravel

2) Route Cache Clear in Laravel

3) View Cache Clear in Laravel

4) Config Cache Clear in Laravel

5) Event Cache Clear in Laravel

6) All Cache Clear in Laravel

7) Cache Clear by Route in Laravel

1) Application Cache Clear in Laravel

This command will clean all application cache clear

Clear Cache:

php artisan cache:clear

2) Route Cache Clear in Laravel

This command will help to clear cache of routes.

Clear Route Cache:

php artisan route:clear

3) View Cache Clear in Laravel

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

Clear View Cache:

php artisan view:clear

4) Config Cache Clear in Laravel

This command will help to clear cache of config.

Clear Config Cache:

php artisan config:clear

5) Event Cache Clear in Laravel

This command will help to clear cache of events.

Clear Event Cache:

php artisan event:clear

6) All Cache Clear in Laravel

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

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...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Custom Login and Registration Example

Read Now →

How to Create Custom Log File in Laravel?

Read Now →

Laravel Jetstream Login with Username or Email Example

Read Now →

Laravel Event Broadcasting with Socket.io and Redis Example

Read Now →

How to Clear Log File using Command in Laravel?

Read Now →

How to use Login Throttle in Laravel?

Read Now →

Laravel Login with Linkedin using Socialite Package

Read Now →

How to Get Logged in User Data in Laravel?

Read Now →

How to Get Current Route Name in Laravel?

Read Now →

Laravel Clear Cache from Route, View, Config Example

Read Now →

How to Setup Cron Job in Laravel?

Read Now →

How to Get Query Log in Laravel Eloquent?

Read Now →

Laravel Create JSON File & Download From Text Example

Read Now →