Flush all cache in Laravel 4
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Flushing Cache in Laravel 4: A Comprehensive Guide for Developers
Introduction
In the world of web development, cache is an essential tool that helps optimize application performance significantly by storing commonly accessed data temporarily. In Laravel 4, you have the option to use a file-based cache storage driver to store your cached items. However, sometimes you might need to flush or delete the entire cache for several reasons, and this article will guide you through different methods of flushing all the cache in Laravel 4.
Flushing Cache Using Artisan Commands
Artisan, Laravel's command-line interface (CLI), offers a convenient way to manage cache contents. Following are some useful artisan commands for managing cache:
1. Clear Cache by Application Type:
- To clear all cache data for the entire application, use the `cache:clear` command:
```bash
php artisan cache:clear
```
2. Clear Specific Cache Types:
- Use these commands to delete specific types of caches, such as configuration and filesystem cache:
```bash
# Configuration cache
php artisan config:clear
# Filesystem cache
php artisan route:clear
php artisan view:clear
```
3. Clear Cache For All Application's Service Providers:
- This command deletes all cached data related to service providers by clearing the `config/compiled.php` file:
```bash
php artisan config:cache
```
Note that if your Laravel 4 application is using a different cache storage driver, you might need to adapt these commands according to the respective documentation.
Flushing Cache Through Code
In some scenarios, you may want to programmatically flush all cache data within your application code. For this, we can use the `Cache::flush()` method provided by Laravel 4's Cache facade:
```php