“Heard about Sevalla? They let you deploy PHP apps with ease.” Claim $50 →

8 ways to clear Laravel's cache

2 minutes read

8 ways to clear Laravel's cache

Introduction + TL;DR

When in doubt, clear the cache. To instantly clear all Laravel caches (routes, config, events, views, and more), run:

php artisan optimize:clear

This command clears these items:

  • Configuration cache
  • Bootstrap files cache
  • Auto-discovered events cache
  • Application cache
  • Routes cache
  • Views cache

Heads up: Ideal for development, but avoid running frequently in production—Laravel needs time to rebuild caches.

Terminal after running php artisan optimize to clear Laravel cache

Clear individual Laravel caches

Do you prefer more granular control? Laravel has commands for that too.

Application cache

Clear the entire app cache:

php artisan cache:clear

Clear a single entry:

php artisan cache:forget <key> [store]

Clear caches by tag (default store only; specify --store if needed):

php artisan cache:clear --tags tag1,tag2

Programmatically clearing cache

Use Laravel’s Cache facade:

use Illuminate\Support\Facades\Cache;

Cache::forget('key');
Cache::flush();

Or the simpler helper:

cache()->forget('key');
cache()->flush();

Learn more about caching.

Config cache

Clear configuration cache easily:

php artisan config:clear

Laravel deletes bootstrap/cache/config.php, forcing fresh configurations.

Learn more about config caching.

Event cache

Clear cached event listeners:

php artisan event:clear

Useful after adding new listeners/events.

Learn more about event caching.

Routes cache

Clear routes quickly:

php artisan route:clear

Laravel deletes bootstrap/cache/routes-v7.php, applying updates immediately.

Learn more about route caching.

Scheduled tasks cache

Clear scheduled tasks cache:

php artisan schedule:clear-cache

Caution: Only use in production when troubleshooting task overlaps. Learn more.

Views cache

Clear cached views instantly:

php artisan view:clear

Laravel empties storage/framework/views, forcing regeneration.

Learn more about optimizing views.

Bonus: Completely disable caching

Disable caching entirely by editing .env:

CACHE_DRIVER=null

Useful for testing or debugging.

Important: When NOT to clear cache

  • Production deploys: Strategically cache (config:cache, route:cache) instead.
  • Routine cron jobs: Frequent clearing slows your app down.

Clear caches deliberately during maintenance or deploy windows.


Did you like this article? Then, keep learning:

2 comments

Guest