Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Clear the Cache in Laravel

This guide shows you the commands that clear Laravel's different caches. Use them when your changes do not show up.

How-To Guides2 min read6 steps

What is Laravel cache?

Laravel is a popular PHP framework for building websites. A framework is a ready-made base that saves you from writing everything yourself. To run faster, Laravel saves some work in cache files. Cache is a store of saved results. If you change a setting or a route and the site still acts the old way, the cache may be stale. Clearing it fixes that.

You run these commands with Artisan. Artisan is Laravel's built-in command tool. You need SSH access. SSH is a safe way to type commands on a server from far away. Ask Hostvento support if your plan includes it.

Steps

  1. Log in to your server with SSH.
  2. Go to your Laravel project folder, the one that has a file named artisan.
    cd /path/to/your/project
  3. Clear the application cache.
    php artisan cache:clear
    This removes data your code has stored in the cache.
  4. Clear the configuration cache.
    php artisan config:clear
    Use this after you edit your .env file.
  5. Clear the route cache.
    php artisan route:clear
    Use this when new routes do not work. A route is a web address your app knows about.
  6. Clear compiled view files.
    php artisan view:clear
    Views are the page templates. Use this when a template change does not appear.

Clear everything at once

php artisan optimize:clear

This one command clears config, route, view, event and compiled caches in newer Laravel versions.

Build the cache again

On a live site, caching speeds things up. After clearing, you can rebuild it.

php artisan config:cache
php artisan route:cache
php artisan view:cache
Tip: If a command does nothing, check that you are in the right folder and that the storage folder is writable.

If you cannot use SSH

You can delete the files inside bootstrap/cache and storage/framework/cache with the File Manager. Do not delete the folders themselves. Take a backup first.

Quick recap

  • Use php artisan cache:clear for app cache.
  • Use config:clear, route:clear, view:clear for the others.
  • optimize:clear does most of it in one go.