How to clear all cache in Laravel 5

By | September 2, 2019

Hello Coders !! Very Ofter you will have this question that How to clear cache in Laravel. So this tutorial is about clearing all types of cache in Laravel 5. while development in laravel many times we faced that latest code is not reflecting on front-end and we do all possible changes but changes not reflect on output.

This will happen because laravel supports popular caching at backends like Memcached and Redis out of the box. So this tutorial will help you with clear cache in a different.

How to clear all cache in Laravel 5- Terminal

So first of all to use this cache clear commands you need to open terminal and reach up-to your project directory. Something like this.

cd /var/www/html/{Project Name}

1. Clear Application Cache

To clear application cache

php artisan cache:clear

2. Clear route cache

To clear route-cache

php artisan route:cache

3. Clear config cache

To clear config cache

php artisan config:clear

4. Clear compiled view files

To clear compiled view files in Laravel project

php artisan view:clear

This above all is the commands that you can run in your terminal to clear the cache of your project because sometimes you are developing and such change is not reflecting in your output at that without wasting much time you can quickly run this command in your terminal and clear all the cache this will save your time.

Apart from the above commands if you want to use another method for clear cache then you can use the below way.

5. Clear cache using URL

Sometime some shared hosting providers will not allow you to use SSH access so at that time you can create your custom action to clear the cache.

For that, you just need to create one route in route files and you are done.

Route::get('/clear-cache', function() {
    Artisan::call('cache:clear');
    return "your cache has been cleared";
});

Now you just need to call this route directly from URL and it will work!! Now you are done with How to clear all cache in Laravel 5.

For more article visit this link. Enjoy coding !!

Leave a Reply

Your email address will not be published. Required fields are marked *