I sat down with JMac for the Laravel Creator Series to talk about something we just finished on our end: caching Laravel News at the edge using his Fast Laravel course and Cloudflare. We treated the site as a case study, and now that it's deployed, we wanted to share what we did and where we got stuck.
The interesting part is that Laravel News is a high-traffic site whose content is changing constantly. New articles, new links, new sponsors, the toast notification at the top. A lot of people assume a page like that can't be cached. The whole point of this conversation is that it can.
Start with Your Top Pages
Jason took a systematic approach. You look at your request traffic, find your highest-hit pages, and cache those first, then work your way down the list until the top requests are just low-traffic sub pages. For us that came down to about five pages:
- The home page
- The blog page
- The article detail page (the posts themselves)
- The community links page
- The recent links page
Three Things We Had to Work Through
The site is mostly static but dynamic in a few specific places, so there were three main challenges.
Dropping Livewire where we didn't need it. The site was built so that nearly everything was a Livewire component, but only the newsletter form actually used Livewire's reactive nature. Everything else was really just Blade templates. Converting those back to plain Blade components was a super straightforward refactor, and it isolated the few areas that genuinely need to stay dynamic.
Keeping the dynamic bits dynamic. A few pieces can't be frozen into a cached page: the toast notification, the newsletter, and the sponsor and partner slots that rotate per request so the same partner isn't shown all day. We were already using Alpine for Livewire, so we added Alpine AJAX and used it to swap those components out on page load.
Two caching layers competing. Laravel News runs on Laravel Cloud, which offers edge caching built into the platform and uses Cloudflare underneath. Since we were already on Cloudflare directly, the two layers competed, and it was hard to tell whose policies were in effect or to bust the Cloud layer cleanly. The Laravel Cloud team was super supportive while we diagnosed it, but in the end it was simpler to bypass the Cloud rules and use our Cloudflare directly. You get all the same benefits underneath.
Busting the Cache When Content Changes
We bust cache on deploy like any other site, but the real work is clearing it when an article is published or links get approved. Most of that runs through Laravel model events. When an article updates, we listen for the updated event and clear that specific article, plus the home page and blog page since a recent post shows up there too.
The tricky one was scheduled articles. We write articles the night before and schedule them to publish at 9am, so there's no event firing in the moment the post goes live, just a query comparing against published_at. The simplest fix was to piggyback on a command we already run to share new posts to social media. That command now also clears the home page, blog, article, and links pages. Worst case, a page is stale for about five minutes while it runs.
It Works Anywhere
Jason was clear that none of this is specific to Laravel Cloud. As long as you have Cloudflare in front of your app, it works on any server. He runs Laravel Shift on a $5 a month DigitalOcean box that handles around 50,000 requests a day with the entire public-facing side cached, and he sees response times around 20 milliseconds from the edge.
The one current exception is Livewire, since it relies heavily on the session for its reactivity. Jason is talking with Caleb Porzio about an anonymous component that could come to life after a page loads. Inertia, React, and anything else doing API calls are all fine.
For us the results were immediate. Laravel News went from caching in the teens to a majority of requests cached, with spikes up toward 70%, and the site just feels faster. The next step is going back in a quarter or so to see if all that reduced server traffic lets us drop down to a lower compute tier without anyone noticing.
Check It Out
Give the video a watch for the full conversation, and go check out Fast Laravel. As Jason put it, edge caching is one of those forgotten practices worth taking another look at, and once you learn it you can carry it forward to every site you build.