• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Clear Cache in Laravel 7/6/5

Written by Rahul, Updated on July 23, 2020

Many times you face an issue that any changes to the Laravel application are not reflecting on web interfaces. This occurred due to the application is being served by the cache. This tutorial will help you to clear the cache in the Laravel application.

Clear Cache in Laravel (Terminal)

Log in to the system running your Laravel application and open a terminal. Then navigate to your Laravel application code. Here you can issue the commands to clear cache as followings:

  1. Clear Application Cache

    Run the following command to clear the application cache of the Laravel application.

    php artisan cache:clear
    
  2. Clear Route Cache

    To clear route cache of your Laravel application execute the following command from the shell.

    php artisan route:clear
    
  3. Clear Configuration Cache

    You can use config:clear to clear the config cache of the Laravel application.

    php artisan config:clear
    
  4. Clear Compiled Views Cache

    Also, you may need to clear compiled view files of your Laravel application. To clear compiled view files run the following command from the terminal.

    php artisan view:clear
    

Clear Cache in Laravel (Browser)

Most of the shared hosting providers don’t provide SSH access to the systems. In that case, you can clear the Laravel cache by calling the URL in the browser. You can simply place the below code in your routes/web.php file of the Laravel application. Then access this URL in the browser to clear the cache of the Laravel application.

1
2
3
4
Route::get('/clear-cache', function() {
    Artisan::call('cache:clear');
    return "Cache is cleared";
});

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

19 Comments

  1. Avatar Iliqn Reply
    September 24, 2020 at 3:29 pm

    Thanks you 🙂 Be safe

  2. Avatar Walfrido Reply
    August 14, 2020 at 1:21 pm

    Thanks a lot. It’s very useful for me.

  3. Avatar Yash Reply
    August 5, 2020 at 11:58 am

    The question is pretty clear.

    php artisan cache:clear
    Is there any workaround to clear the cache like above we using in CLI. I am using a popular shared hosting service, but as per my plan, I don’t have control panel access.

    ** I want to clear the views cache.**

  4. Avatar Rosen Vlasev Reply
    June 16, 2020 at 12:12 am

    All in one

    Route::get(‘/clear-cache’, function() {
    Artisan::call(‘optimize:clear’);
    echo Artisan::output();
    });

  5. Avatar Nisha Roy Reply
    March 9, 2020 at 5:31 pm

    Thank you very much. It helps me a lot as a beginner in laravel.

  6. Avatar shamnas cv Reply
    November 22, 2019 at 6:19 am

    Thanks buddy. Are you a Laravel developer?

  7. Avatar Anupama Reply
    November 15, 2019 at 2:32 am

    Please change clear route cache from ‘php artisan route:cache ‘ to ‘php artisan route:clear’.

    Thanks,
    Anu

    • Rahul Rahul Reply
      November 15, 2019 at 9:21 am

      Thanks Anupama, I have corrected the command.

  8. Avatar prem Reply
    October 9, 2019 at 5:10 am

    Thanks useful

  9. Avatar Nguyễn Trí Diện Reply
    September 5, 2019 at 4:53 am

    i readed your infomation and I am very impressed for you. Thanks you for your sharing. It is very useful !

  10. Avatar Marco Ruiz Reply
    August 8, 2019 at 8:10 pm

    I have the same problem.
    Calling / clear-cache is enough for all clients to see the same page, or do we have to make the call on each client computer?

  11. Avatar David Wakelin Reply
    August 5, 2019 at 3:48 pm

    Please fix this error in your post:
    php artisan config:cache does not clear your cache. This will cause problems with unit tests.
    It should be php artisan config:clear

  12. Avatar David Reply
    July 13, 2019 at 8:59 am

    thankss for sharing

  13. Avatar Huntelaer Reply
    July 10, 2019 at 12:28 pm

    In the browser:

    instead of Artisan simply use

    cache()->clear();

  14. Avatar Larry Reply
    May 31, 2019 at 11:02 pm

    IMPORTANT! #3 should be:

    php artisan config:clear

    NOT config:cache

    Hey, Rahul, would you mind updating the article? I spent a bunch of time debugging a problem with env() after running config:cache. Your article has a high Google result for “laravel clear cache” and it would be nice for the information to be correct.

  15. Avatar hejian Reply
    May 1, 2019 at 1:22 am

    php artisan route:cache ?? clear

  16. Avatar Jhon Corner Reply
    April 26, 2019 at 12:50 am

    I ran the commands and the laravel site stop working: appear 404
    Not Found. Any help will be appreciate.

    Thanks

    • Avatar Deepak Reply
      May 21, 2019 at 8:32 pm

      php artisan route:cache is to cache the route

      Run
      php artisan route:clear
      php artisan config:clear

  17. Avatar Swiya Chatterjee Reply
    January 24, 2019 at 4:41 am

    Laravel provides an expressive, unified API for various caching backends. Also, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the filesystem. I would like to add that the above-listed steps to clear cache are easy to follow and important too for Laravel Application Development.

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy