Most slow Laravel apps I get asked to fix don't need a bigger server. They need a caching plan. Not "wrap everything in Cache::remember" — an actual plan for what gets cached, for how long, and how it gets invalidated.
Here's the approach I use on client projects, after shipping 100+ Laravel builds.
1. Start with the config, route and view caches
Before touching application code, make sure your deploy script runs:
php artisan config:cache php artisan route:cache php artisan view:cache php artisan event:cache These are free wins. The catch: once config:cache runs, env() calls outside config files return null. If something breaks after deploy, grep for env( in your app/ folder first.
2. Cache expensive reads, not every read
A query that runs in 3 ms doesn't need caching. Caching it adds a network hop to Redis and an invalidation problem you now own.
What I do cache:
- Dashboard aggregates (counts, sums, charts) that hit large tables
- Settings / feature flags loaded on every request
- Third-party API responses (exchange rates, shipping quotes, geo lookups)
- Navigation menus and category trees built from nested queries
$stats = Cache::remember("dashboard:stats:{$teamId}", now()->addMinutes(10), function () use ($teamId) { return [ 'orders' => Order::where('team_id', $teamId)->count(), 'revenue' => Order::where('team_id', $teamId)->sum('total'), ]; }); 3. Never cache these
- Anything with a user's permissions baked in under a shared key. I've seen admin menus leak to normal users this way.
- Cart, checkout and payment state. Stale data here costs real money.
- Paginated lists with filters, unless you're careful with keys. The key explosion usually isn't worth it.
- Whole Eloquent models with loaded relations for long TTLs — they go stale silently.
4. Use cache tags (or key prefixes) so invalidation is boring
With Redis or Memcached you can tag entries and flush a group:
Cache::tags(['products', "team:{$teamId}"])->remember($key, 3600, fn () => ...); // in a ProductObserver Cache::tags(['products'])->flush(); If you're on the file or database driver, tags aren't supported — use a versioned prefix instead (products:v{$version}:...) and bump the version on write.
5. Put invalidation next to the write
Invalidation logic scattered across controllers is how stale data bugs happen. I keep it in model observers or events, so any code path that saves a Product clears the right keys.
6. Protect against cache stampedes
When a popular key expires, 200 requests can hit the database at once. Laravel's atomic locks help:
$value = Cache::lock("lock:report:{$id}", 10)->block(5, function () use ($id) { return Cache::remember("report:{$id}", 600, fn () => Report::build($id)); }); For really hot keys, Cache::flexible() (stale-while-revalidate, Laravel 11+) serves the old value while refreshing in the background.
7. Measure before and after
Turn on Telescope or Debugbar locally, note query counts and response time on your heaviest pages, then cache. If the number didn't move, remove the cache — it's just complexity.
Quick checklist
- [ ] config/route/view/event cache in deploy script
- [ ] Redis as cache driver in production
- [ ] Cache only measured slow reads
- [ ] No per-user data under shared keys
- [ ] Invalidation in observers/events
- [ ] Locks or
flexible()on hot keys
I'm Arun Tyagi, a freelance Laravel developer working with businesses in India, Dubai and beyond. If your app is slowing down and you want a second pair of eyes, you can find my work at aruntyagi.com.