Performance tuning in Laravel often starts with database indexes, query optimization, or infrastructure upgrades. But in many cases, the biggest gains come from a much simpler realization: large portions of your Laravel application are effectively static.
In a recent interview, I sat down with JMac, the creator of Laravel Shift and the new Fast Laravel course, to walk through exactly how Cloudflare page caching can transform a production Laravel application.
We used Laravel News itself as the case study and here are some of the highlights:
Why Laravel Apps Often Miss Out on Caching
Out of the box, Laravel is not cache-friendly at the page level. Sessions, middleware defaults, and dynamic rendering all signal to CDNs that responses should be treated as personalized. As a result, many Laravel applications sit behind Cloudflare but never actually benefit from page caching.
In this case, Laravel News had Cloudflare enabled primarily for DDoS protection. Assets like images, CSS, and JavaScript were cached automatically, but HTML responses were consistently bypassing the cache.
The result was a site that looked static to users but behaved like a fully dynamic application on every request.
The Homepage Problem (And Opportunity)
For most sites, the homepage is the most visited page by a wide margin. Laravel News is no exception. Despite being built with Livewire, the homepage has no interactivity, no polling, and no user-specific content. It only changes when a new article is published.
That makes it an ideal candidate for page caching.
Jason explains that even relatively short cache windows can yield massive wins. If a homepage can be cached for even 30 to 60 minutes, the reduction in compute load and the improvement in response times are immediate and measurable.
Livewire, Blade, and Static Rendering
One of the most interesting parts of the discussion centers on Livewire. While Livewire is an excellent tool for interactive interfaces, using it for non-reactive pages can unintentionally block caching opportunities.
In this case, the homepage used Livewire components primarily as data loaders with cached computed properties. While this works, it still forces Laravel and PHP to execute on every request.
The proposed refactor is intentionally minimal: replace non-reactive Livewire components with Blade components or simple cached queries. The behavior stays the same, but the page becomes fully cacheable at the CDN level.
Cloudflare’s Free Tier Is Often Enough
A key takeaway from the conversation is how much Cloudflare offers on its free plan. Page caching rules, cache control headers, WAF rules, redirects, and even services like Turnstile are available without upgrading.
The Fast Laravel course focuses on applying these tools surgically rather than re-architecting applications. The goal is not to fight Laravel’s conventions, but to work with them more intentionally.
Performance Gains and Cost Savings
Beyond faster response times, effective caching has a direct impact on infrastructure costs. When fewer requests reach PHP and your application servers, CPU usage drops, memory pressure decreases, and scaling becomes less reactive.
As Laravel News prepares to migrate to Laravel Cloud, this creates an opportunity to measure how CDN-level caching affects real-world compute usage and monthly costs.
A Practical Path to Faster Laravel Apps
The big takeaway from this discussion is straightforward: you do not need to rewrite your application or abandon Laravel’s ecosystem to achieve meaningful performance gains.
By identifying truly static pages, understanding how framework defaults affect caching, and configuring Cloudflare correctly, many Laravel apps can see immediate improvements in both speed and cost.
This upcoming Laravel News case study will put those ideas into practice, and the results should be useful for anyone running Laravel in production today.
Check out JMac's products:
Episode Transcript
Eric Barnes (14:36.855) Hey everyone, welcome to our channel. And with me today is J-Mac, who has a sweet new course called Fast Laravel. So J-Mac, tell us a little elevator pitch. What's Fast Lerville?
JMac (15:10.2) Yeah, FastLayerVal is a new video course specifically about caching your layerable applications, page caching them with CloudFlare. I think that's the fastest way to really improve the performance of your site. You don't have to worry about code optimization or tuning the database. You can just turn on page caching with CloudFlare, really any CDN, because the reality is a lot of your site, even with the layerable app, is static. It doesn't necessarily change. And I think that's what we're going to
get into today to kind of prove that but but that's what the course is on it's a 30 video course very tactical these surgical refactors you can do to just take your sight from probably hundreds of millisecond response times to like 40 millisecond response times and I did it all for shift lair about shift comm so I kind of use that as like the original case study and made a video course around it
Eric Barnes (16:01.179) Exactly as sweet. Yeah, so we've been talking sort of, I don't know, since right before the launch and I use Cloudflare already for Laravel news and I was like, you know, can you come and look at this and just tell me what you know, how to improve basically Laravel news. And so this all works out so we can we can kind of have a conversation about it, kind of show you all some stuff and kind of get a, you know, a way to go forward to, you know, help everything. So so with that said, let's let's jump in here.
JMac (16:14.382) Yeah.
JMac (16:30.542) Yeah, yeah, it's funny. We, yeah, we kind of got called out because, you know, I was writing some articles before the course for Laravel News to kind of share what I saw. And once I realized that had like a lot more content, I okay, well, I'm just going to make a video course. I shared it on Reddit and yeah, somebody kind of called us out. They were like, they took the post and they were like, oh, well, I inspected the traffic for, you know, Laravel News and userscape and layercasts and
All of them are on Cloudflare, but they're not caching with Cloudflare. And I was like, all right, well, let's do some case studies. So we're to start with Laravel news and see if we can ramp up the caching, make this faster, decrease server costs, all the fun stuff.
Eric Barnes (17:08.751) Yeah, exactly. And sort of a little backstory. So for me, I did Cloudflare just because of the DDoS protection. Like, I have not tuned it at all, not done anything. I just threw it up there. I was like, I'm safe now, so let's just use whatever they give me. So that's why I think it's a really cool course, because then you can start learning more about actually what Cloudflare provides, because they do all kinds of stuff now.
JMac (17:22.315) yeah.
JMac (17:31.094) Yeah, there's a crazy amount of services and that was kind of the beginnings of the course really was like I knew I wanted to do page caching and I knew Cloudflare covered that but it just seemed like they covered so much more and it kind of felt a little daunting and so that's kind of also about the course is like...
It does cover page caching, but in the process, like I get into the WAF rules and the redirection rules and the page caching rules and turnstile and geolocation and just so many services that it ended up, you know, offering the image services. Like, it's just crazy. And maybe they'll turn on the paywall on those someday, but for right now, everything that the course covers is on the free plan, which is kind of incredible.
Eric Barnes (18:14.341) That's awesome. Then I was gonna say now cloudflare was I do remember I am paying. I have a paid account and I'm paying for Arcos. I think it is like a DNS thing, but I have no idea what they I got the sales pitch and it was like, yeah, this sounds good. Let's sign up for that.
JMac (18:26.572) Okay, yeah.
JMac (18:33.122) Yeah. Yeah, they're like general, they're general plan. goes from like zero to a pretty pricey, pretty quick. But everything I cover, all the services that are used in the course are technically on their free plan.
Eric Barnes (18:48.763) Sweet. All right, well, let's jump in. let's, I guess let me pull up, me share my screen. I'll share the Laterville News homepage so we can kind of look at that while we are talking about it.
JMac (18:57.677) Yeah.
JMac (19:01.814) So for most sites, your homepage is gonna, or your landing page is gonna be the most visited page, like by far with a bullet. And like we could jump in, if you've got like analytics, we could jump in, I'm sure you've got some analytics, but we could jump in and see like what the traffic is over the last 30 days to kind of prove that. But my guess is it's a multiple higher than any other page. Now you do have some news pages, like your site's a little different than other sites where like,
If you had a really impressive feature article that made the rounds or went viral, I could see that one cranking up too. But the point here is that your homepage is definitely gonna be number one, probably for most sites. And also too, like we said, the homepage is, generally speaking, in a snapshot, static.
Now again, this is a good case study because it's a news site. So you've got new articles coming out and you've got all sorts of things. So we do need to think about cache busting, which the course, you know, covers and goes into and we'll go into for the case study. But again, from a, from like a design, you know, perspective of the page, like at least for an hour, two hours, three hours, some period of time, relatively short time, this page is static and would benefit from being cached.
Eric Barnes (20:15.717) Exactly, yes. And speaking of stats, yeah, this page is probably three times more popular than anything else on the site every month. Yeah, I think probably three times more traffic comes to this than any other page. So yes, definitely the most visited part of the site.
JMac (20:33.9) So the next thing, that's typically where you want to start, right? We want the biggest bang for the buck. So I think on this, it probably makes sense to start with the homepage and then the article pages. That's gonna give you the most bang for the buck. You can progress from there, but if we really wanna tweak up that...
cache stat on Cloudflare like a kind of demo for the course. Like if you want that graph to go from like 10 % to 60%, 80%, 90 % cache, you really want to focus on your highest traffic pages. So let's talk about like how is this kind of built, right? Cause that's kind of the next thing. Like right now out of the box, Laravel is not cacheable. It uses the session and it's a web framework. It does things by default that
aren't gonna make it cached and that's kind of what that Reddit poster found in this case was like, if we right click and inspect the traffic, you're gonna see like a CF cache status of bypass or dynamic. It's not gonna say hit. Like, you're on Cloudflare, you're using Cloudflare, you can cache with Cloudflare, but we're not.
Eric Barnes (21:37.967) Yes, yes, yeah, they were calling me out. mean, come on, guys, you should just email me. Just kidding. Yes.
JMac (21:44.749) It was a fair call out, yeah, it kind of knocked us both. I'm trying to promote the course and they're like, well, you're not cashing. And it's like, oh, okay. So.
Eric Barnes (21:53.788) That's so true. Yeah. So, yeah. So this homepage is, basically we're just using the live wire everywhere. but it's not at all dynamic, like nothing. Like if you leave this page sitting here for the entire day, it's going to have the exact same thing on it. has now, in 12 hours, if you don't refresh. so all caching is basically, you know, through the lab or component, not anywhere else. And.
JMac (22:03.553) okay.
JMac (22:23.319) Okay.
Eric Barnes (22:23.751) And it never updates unless we publish a new article like the cache never gets cleared anything like that. So it's standard Lobwire, but no reactivity at all
JMac (22:31.96) Okay.
I see. Okay, so it's a LiveWire component, but there's nothing I can click or do on this page that does a wire update call. And when you were saying you have some component or property cache that's happening, you've got computed properties in LiveWire, but you're saying they don't...
Eric Barnes (22:48.271) No.
Eric Barnes (22:54.49) Yeah.
JMac (23:01.686) Again, there's no reactivity with those. Like when you clear those out, this page doesn't somehow automatically know to like, it's not listening for some event and like refreshing itself automatically.
Eric Barnes (23:11.035) Right, exactly. going to let me share the I'll share the code behind the scenes here. Here's here's an example of this home page section. We have the links jobs and you can see it's basically just a live wire using a computed cache. And that's it. It's just doing a query and passing out to a lot of work component. Nothing. Nothing fancy or crazy, I guess.
JMac (23:20.034) Okay.
JMac (23:33.504) Okay. Okay.
JMac (23:38.562) So it's just caching some things. Okay. Okay. So it's caching some things. It's kicking those back. The cat, okay.
I even wonder how much coming off of, I went to that Wire live event, and I know in LiveWire 4 they're a little bit better with some of the caching, but I think there were some gotchas in 3 where computed properties, even when you cache them, aren't as maybe cached as people think. I forget the nuance, but there's something where it's still rendered once per request or something like that.
Eric Barnes (23:57.211) Mhm.
JMac (24:20.748) So again, in the case where we're not having this reactivity, like, you definitely want to cache these things, but I'm wondering how much we're benefiting from LiveWire here.
Eric Barnes (24:30.873) Right, yeah, there's, I'm trying to think of a good answer. don't know if there's any benefit at all to using LiveWire here. Like this is definitely not really what LiveWire is designed for, I would say. But, and then from there, we're just using, you know, the little LiveWire, like in the view, you know, we're just like looping over and using the little components here, here and there, and that's it.
JMac (24:36.865) You
JMac (24:44.44) Yeah.
JMac (24:53.026) Yeah.
JMac (24:59.246) So you've got, so these look like actual blade components that you, I see the latest articles section is live wire, but those look like just blade components. Okay. Okay. Okay.
Eric Barnes (25:02.906) Yeah.
Eric Barnes (25:07.075) Yeah. yeah, you're right. Yeah. Good call. down here, liveware latest articles section. And I don't know. No, it's just a full cash. Yeah. Let me go back there. Let's see. I guess the only, yeah. Yeah. There's nothing there.
JMac (25:14.752) And do you feel like any of those are reactive in any way?
Okay. Okay.
JMac (25:24.834) So generally speaking, LiveWire, much like Laravel, has built, again, web framework. There's some stuff in there that it assumes, like session data. And session data is really what makes a page difficult to cache, right? Because
The presumption is session data is user-specific. We don't want to cache something publicly that's privately user-specific. I noticed on the home page too there was a login thing. If I log in, is there any, does that nav change at all? Or is that too kind of static? Do you just get redirected to an admin page?
Eric Barnes (25:59.438) Yeah, so let me, I'll open it back up here. So yeah, so we have this over here. We have your account. You can click that and that actually sort of behind the scenes, the homepage and everything basically uses the like gas.blade.php layout file. And then if you go into like your account, which is one of the starter kits, it uses the app.layout.blade. then that's the, so basically none of this carries over to the front end. anywhere, nowhere on the front end do we care if you're logged in or not.
JMac (26:14.861) Yeah.
JMac (26:19.798) I see.
Okay.
JMac (26:25.848) Yeah.
Yeah, you're not showing the avatar or anything. Okay.
Eric Barnes (26:28.731) Because we don't do comments, we don't do sort of anything really that is directly to an account. So it doesn't matter, I guess.
JMac (26:36.524) Gotcha. Cool. Yeah. So again, Fast Lirvel is kind of all about like these surgical refactors. Like we're not trying, you know, the goal of the course is to not try to necessarily change your stack. The kind of pitch is it's your Lirvel app, but Fast, right? In this case though, you kind of said yourself like, we're using Livewire, but we're kind of using it interchangeably with these blade components.
Eric Barnes (26:54.395) Mm-hmm.
JMac (27:04.426) And it doesn't seem like there's anything on this page that we actually need it to be reactive. There's nothing really going on. Like if we let the dev console sit in the network tab, we would never see a wire update, live wire update endpoint be called, right? There's nothing you could do on this page. So again, it is static, but we're kind of using these very dynamic tech things that we maybe don't need.
So think that kind of makes it an interesting case study because again, I don't necessarily cover Livewire in FastLayerValve because of its nature. But I think this is a good augment to that to say, okay, if you are using Livewire, but maybe it's in kind of this more limited capacity, there might be an opportunity just to fall that back on a you know, a blade class, a blade component with a class that really just caches those same things.
Eric Barnes (28:00.699) Mm-hmm.
JMac (28:01.486) Because that's really all we're kind of doing. You're just using Laravel's computed property to effectively stuff something in the cache for you.
Eric Barnes (28:07.523) Yeah, yeah, exactly. it's and there's yeah, it works. I was gonna say there's really no no reason. It's just it works.
JMac (28:09.838) It works fine. nothing wrong with it. Yeah, and I'm with you. There's nothing wrong with it. But what we're talking about here, though, is there's nothing wrong with it, but compared against the benefit of being able to cache a highly trafficked page on the site, which actually could mean like...
a better user experience, because the page is being delivered faster, it could mean less compute for you, because now instead of 3x your traffic on the homepage where you are potentially hitting, even if you are caching, you're still hitting your full Laravel Livewire stack and returning a response. Like there's still compute that's happening there. You might not be hitting that database, because it's in your cache, but it's still, PHP is still running somewhere, right?
A lot of PHP code is still running somewhere.
Eric Barnes (29:04.057) Yeah, I'll share this one too. This is the Cloudflare kind of analytics for the site for the to give an idea on how many how many requests are made and like I don't.
JMac (29:06.935) Okay.
JMac (29:14.973) Okay, so seven days, oh wow, seven days you got 1.5, and you got a pretty decent percent cash. Now my guess is that's probably because it's kind of a media heavy, asset heavy site. Like you have a lot of images and a lot of your traffic is images as compared to simple text content of the page.
And those are all, images and stuff are default by Cloudflare. Like you don't even have to turn anything on. They're just gonna attempt to cache your images for a pretty good amount of time. I think like an hour at least.
Eric Barnes (29:45.651) that's true. Yeah. So like basically any image sort of in like your public directory, like your logo or things like that, that would actually make sense. Yeah.
JMac (29:51.798) Yeah. Yeah. Yeah. So it's not surprising that you actually, like when I started this with Laravel Shift, my percent cashed was like seven. know, because I don't have a lot of images. all page heavy, right? It's a lot of text, a lot of JS, a lot of CSS. Now again, Cloudflare by default is going to give you image, JS, CSS, and they kind of just default that to about an hour.
Eric Barnes (30:02.322) wow.
Eric Barnes (30:05.893) Right.
JMac (30:18.038) which again on a highly trafficked heavy media site like L'Hervelle News, it's not surprising to actually see a 20 or 30 % out of the box. But I bet you if we cashed the homepage, I think you'd probably see that jump maybe close to 70%. And then if we cashed all article pages, I think you could be in the 90s.
Eric Barnes (30:30.203) That'll jump.
Eric Barnes (30:38.629) Yeah, yeah, because those those are the two pages, you the homepage and basically the article details page. Those are the most trafficated out of the entire setup. So yeah, those two would be key, I think, to get those dialed in.
JMac (30:42.54) Yeah. Yeah.
JMac (30:50.284) So what I propose is let's, let's, if you're willing to give me access to the code base, I won't share anything crazy, but I'll do a little video where maybe I demo the refactor out of the Livewire component that's not really being used reactively anyway, and we'll just drop it into a blade component. And we'll...
enable kind of the Fastler-Vell configuration, which is a shift now. You can run a free shift and it'll automatically put in the configuration to be able to cache pages the way that the course talks about.
Eric Barnes (31:21.179) Wait, when did that come out? Because I have not heard of this. Okay, I was gonna say...
JMac (31:24.782) Like Monday, I've been ships like crazy. I built the Livewire 4.1 yesterday. Last week I built FastLabel. I'm making a Label Cloud Prechecker. There's a lot of stuff. I'm getting nuts. I'm getting nuts in 2026. I gotta maintain relevance.
Eric Barnes (31:36.059) Nice. Okay, sweet. Yeah, that'd be awesome.
Yeah, and speaking of cloud, I have agreed I'm going to switch. So right now, they're all news is on Forge with the node server, which is a Kama or somebody now. Anyway, I'm going to do a live stream with the cloud team next week and we're going to convert the site to cloud. So you know, however that brings in, you know, we can we can work around that too for caching and stuff.
JMac (31:50.808) Okay. Yeah, yeah, yeah.
JMac (31:58.629) nice.
JMac (32:05.91) No, I think that'd be really cool, because yeah, what you could do is you could get on there. That really wouldn't affect your Cloudflare stats that we're looking at here. But, you know, I kind of mentioned, well, saved on compute. I mean, if you move to cloud, then you're going to get a lot more tune in on compute probably. So it'd be interesting to see, does your monthly Laravel cloud costs go down when maybe we cache more pages?
Eric Barnes (32:18.48) Mm-hmm.
JMac (32:30.926) unless requests are coming through, right? Because it kind of depends on which plan you're on there. Like if you're just on like a plan, but if you're on one of their like compute requests, like CPU kind of processy plans, like I could see you actually saving potentially if we were able to cache here. So we could do like a...
Eric Barnes (32:49.091) yeah, that'd be a good, yeah. I was gonna say we could, yeah, we could convert the site, then convert the homepage to better cash. And then you can kinda, we can do a cost comparison too. Yeah, that would be awesome.
JMac (33:03.566) Yeah, that would be cool. Yeah, I I think it would go down depending on the plan. I mean, unless you just buy like, I want, like, you know, I'm on DigitalOcean with some of my stuff. So like, they're just kind like, oh, I want like a four CPU, you know, eight RAM. You just kind of pay for it and that's what you get. But I think cloud obviously is more kind of dynamically scalable. I'd be curious. Yeah, I'd be curious to cost compare that too. So that'd be a fun case study as well.
Eric Barnes (33:28.591) Yeah, that would be, we could get two for the price of one here.
JMac (33:32.342) Yeah, cool. Well, yeah, let's do it. Yeah, I wasn't aware of the Livewire thing, but I think it's a good, it's still a good use case. It might be a slightly bigger change, but I also, again, for the limited way in which it's being used, it might not be that bad. So let me do a little, my own little video on it where I'm changing the code. I'll get a little more code heavy. You can get me some access off.
off screen here, but yeah, let's let's do that and then we'll reconnect. Deploy it. Turn on some buttons in cloud flare and let's let's watch that number crank up. And maybe that server costs go down.
Eric Barnes (34:11.547) That'd be awesome. Yes. It's even better, right? Yeah. Cause even now like I'm paying like 80 bucks a month and I'm trying to word this the right way. I was really, I was originally like a $20 a month server and then it like max out one time and I was like, screw this. here's $80 a month and I didn't change anything. I just paid more money. That way I didn't have to worry about it. Yeah. It's like, I ain't got time for this.
JMac (34:34.19) You pull, yeah, you pull an Ian Landsman and you just bumped it up. You got, yeah. You got off that childlike server. I'm still on the childlike server. I'm proud. I'm proud. So, maybe we'll try to get you back to the childlike server with Fastler Veld.
Eric Barnes (34:43.269) Ha ha ha!
Eric Barnes (34:47.035) Oh, that's great. That's right. That's where we need to be. But yeah, that sounds awesome. And I was going to say, you know, as we go away off this, you know, if anybody listening, go check out Fast Laravel, Laravel Shift, everything Jason creates, it's always awesome. And he is the regex king. Yes, yes.
JMac (35:09.422) I know I'll wear my reg exert for the next one.
Eric Barnes (35:16.507) Alright, thanks for tuning in everybody. Alright. that was good.
JMac (35:16.802) Alright dude, sounds good.