Full-page caching in Laravel without serving stale content
- Text
- Mihai Solomon
- Date
- Read
- 1 min
Response caching makes a content site fly — until an editor hits Publish and the old page keeps showing.
The rule#
If a save can change what a visitor sees, the cache must not survive that save.
The implementation#
One model observer flushes the whole response cache on any content save. A scheduled job runs every minute and flushes again when a post's publish time has just passed, because scheduled publishing fires no model event.
Why not something smarter?#
Selective invalidation is a great way to ship a bug where one page is stale forever. For a site with a few hundred pages, re-warming is cheap; correctness isn't.
- Text
- Mihai Solomon
- Date
- Read
- 1 min