ItSolutionStuff.com

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

By Hardik Savani • September 4, 2024
Laravel

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

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 11 Guzzle HTTP Request Example

Read Now →

Laravel 11 Change Date Format Examples

Read Now →

Laravel 11 Yajra Datatables Example Tutorial

Read Now →

Laravel 11 REST API Authentication using Sanctum Tutorial

Read Now →

Laravel 11 Markdown | Laravel 11 Send Email using Markdown Mailables

Read Now →

Laravel 11 Ajax Form Validation Example Tutorial

Read Now →

Laravel 11 Ajax Image Upload Example

Read Now →

Laravel 11 Authentication using Jetstream Tutorial

Read Now →

Laravel 11 Authentication - Install Laravel 11 Breeze Tutorial

Read Now →

How to Send Email using Gmail in Laravel 11?

Read Now →

Laravel 11 Import Export Excel and CSV File Tutorial

Read Now →

Laravel 11 Generate PDF File using DomPDF Example

Read Now →

Laravel 11 Multiple Image Upload Tutorial Example

Read Now →

Laravel 11 CRUD Application Example Tutorial

Read Now →