People searching “Laravel cache Vue page” remember the whole post list, including drafts, under one key. The next visitor sees the first visitor’s rows. Cache a public number. The page that shows private rows stays on the CRUD guide query.
TL;DR
- Cache::remember stores a public count.
- Forget that key when a post is created.
- Do not cache one user’s drafts under a global key.
- Do not
Cache::remembera paginator that calledwhere('user_id', auth()->id())under a key with no user id in it.
The fix#
$stats = Cache::remember('stats.posts', now()->addMinutes(5), function () {
return ['count' => Post::query()->count()];
});Pass $stats as a prop. When a post is created or deleted, forget the key in that same request:
Post::create([...]);
Cache::forget('stats.posts');Five minutes is a choice for a homepage count, not for an editor.
What to avoid#
Gotcha
Do not Cache::remember a paginator that called where('user_id', auth()->id()) under a key with no user id in it. Do not cache the rendered Inertia page in a way that includes the CSRF token. That token belongs to one session.
FAQ#
How do I cache a prop and forget it on write?
Cache::remember stores a public count. Forget that key when a post is created. Do not cache one user's drafts under a global key.
What goes wrong with Laravel cache Vue page?
Many developers remember the whole post list, including drafts, under one key. Do not Cache::remember a paginator that called where('user_id', auth()->id()) under a key with no user id in it.



