How to clear cache using URL in Laravel

how to clear cache using url in laravel

In this article we will Learn about how to clear cache using URL,I will show you how you can clear route:cache, config:cache, view:cache using URL.

This method is very helpful when you are using shared hosting, at that time going to the terminal and clearing cache from there is a very time taking process, so I will guide you on how you clear cache using URL in laravel.

To clear the cache using the URL go to your routes/web.php and add the below code into it.

Route::get('clear-cache', function() {

    Artisan::call('cache:clear');

    Artisan::call('view:clear');

    Artisan::call('route:clear');

    Artisan::call('config:clear');

    return "Cache is cleared...";

});

to run the above command go to your browser address tab and enter your domain-name/clear-cache.

The above command will clear cache,view,route and config.

If you want’s to clear all your cache in one command then use the below command in your terminal

php artisan optimize:clear

To clear composer run the below command

composer dump-autoload

To clear Route Run the below command

php artisan route:clear

To clear route cache, Run the below command

php artisan route:cache

To clear config cache, Run the below command

php artisan config:cache

To clear config,Run the below command

php artisan config:clear

Read Also: Laravel 6 Crud Application

I hope you like the above article,still confused feel free to comment.

0 0 vote
Article Rating

Do you want to hire us for your Project Work? Then Contact US.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x