No Compromises · Joel Clermont and Aaron Saray
When someone says your app is slow and you need caching, do you actually know which layer of caching they are talking about? In the latest episode of the No Compromises podcast, we discuss the many different forms caching takes in a Laravel application and why reaching for the cache facade is not always the answer. We walk through caching from the outside in, starting with edge caching via Cloudflare, moving into Laravel's cache facade for third-party API calls, and all the way down to memoization with the Once helper for expensive in-request calculations. We also make the case that storing data in a database table can be a perfectly valid caching strategy, and that the right question to ask is not whether to cache but what kind of caching actually fits the problem. (00:17) - Why caching means different things to different people (02:04) - Edge caching with Cloudflare explained (05:33) - When a database table beats the cache facade (07:45) - Memoization with the Laravel Once helper (09:19) - Silly bit We have seen every caching mistake in the book. Our code review will find yours.Get practical Laravel tips like these delivered to your inbox every day by subscribing to our newsletter.
0:00JoelWelcome to No Compromises. A peek into the mind of two old web devs who have seen some things. This is Joel.
0:08AaronAnd this is Aaron.
0:17So, in general, I know there is this concept on the internet of caching things, right? And basically, that means keep a copy of it,
0:23I guess, and just serve that copy again instead of getting the real one. But I'm going to play a little bit of a dummy here,
0:29a little bit of a devil's advocate, Joel. And I'm going to pretend like I don't actually know much about caching.
0:33JoelOkay.
0:34AaronBecause I think I'm going to ask you these questions because it's going to lead us through an interesting cache arc, a story arc through all the tools that
0:40we have evolved, involved, available inside of Laravel. So, in general, if I were to say to you, "I think I need caching. My website is slow."
0:50JoelOkay.
0:51AaronWhat was the type of questions you'd ask me about first to kind of figure out why I'm even bringing that up?
0:57JoelI mean, I would say like, "What's slow?" right?
1:02AaronYeah.
1:03Joel"Is it a particular page? Is it the site as a whole? Is it like this once? You know, it's e-commerce site, it's like this one product takes forever to load,
1:12but like all the other ones load fine." Like, I would definitely start like, "What's slow? And what's the pattern for when it's slow?"
1:19AaronOkay. So, let's just say then that we've had... I'm going to skip a lot of the part of the conversations just to make this a shorter podcast.