Skip to main content
ubuntuask.com

Back to all posts

How to Clear Cache In Laravel?

Published on
3 min read

Table of Contents

Show more
How to Clear Cache In Laravel? image

To clear cache in Laravel, you can use the Artisan command php artisan cache:clear. This command will clear all cache data stored in the application. Additionally, you can also clear specific cache types such as route cache, configuration cache, view cache, and compiled views by using the respective Artisan commands php artisan route:clear, php artisan config:clear, php artisan view:clear, and php artisan [clear-compiled](https://studentprojectcode.com/blog/how-to-clear-an-element-inside-an-iframe). By running these commands, you can remove any cached data in your Laravel application and ensure that your application is using the latest updated content.

How to clear Laravel view cache manually?

To clear the Laravel view cache manually, you can run the following command in your terminal:

php artisan view:clear

This command will remove all compiled view files in the storage/framework/views directory. This can be useful if you have made changes to your views and want to see the changes reflected immediately without waiting for the cache to clear automatically.

How to clear cache in Laravel using cache driver?

To clear the cache in Laravel using the cache driver, you can use the cache:clear Artisan command. Here's how you can do it:

  1. Open your terminal.
  2. Run the following command:

php artisan cache:clear

This command will clear the entire cache for your Laravel application. It will clear all stored cache data for the specified cache driver (e.g., file, database, redis, memcached).

After running the command, the cache will be cleared, and your Laravel application will start using fresh data.

How to clear cache in Laravel website manually?

To clear the cache in a Laravel website manually, you can follow these steps:

  1. Open your terminal or command prompt.
  2. Navigate to the root directory of your Laravel project.
  3. Run the following command to clear the application cache:

php artisan cache:clear

  1. Additionally, you can also clear the route cache by running the following command:

php artisan route:clear

  1. If you are using view caching, you can clear the view cache by running the following command:

php artisan view:clear

  1. You can also clear the config cache by running the following command:

php artisan config:clear

  1. After running these commands, your cache should be cleared and your Laravel website should be updated with the latest changes.

Please note that clearing the cache may result in a temporary slowdown in website performance as the cache is rebuilt.

How to clear cache in Laravel development environment?

To clear the cache in Laravel development environment, you can use the following commands in your terminal:

  1. Clearing Configuration Cache:

php artisan config:clear

  1. Clearing Route Cache:

php artisan route:clear

  1. Clearing Compiled Views:

php artisan view:clear

  1. Clearing Application Cache:

php artisan cache:clear

  1. Clearing Compiled Classes:

php artisan clear-compiled

After running these commands, your cache will be cleared and you should see the changes reflected in your Laravel development environment.

How to clear cache in Laravel using command line?

To clear cache in Laravel using command line, you can use the following commands:

  1. To clear application cache:

php artisan cache:clear

  1. To clear configuration cache:

php artisan config:clear

  1. To clear route cache:

php artisan route:clear

  1. To clear view cache:

php artisan view:clear

  1. To clear compiled views:

php artisan view:clear

You can run the above commands in your command line interface to clear cache in Laravel.