This is why you need caching

  Рет қаралды 43,621

Web Dev Cody

Web Dev Cody

Күн бұрын

Be sure to checkout upstash.com/?u... if you want to set up globally enabled caching in your applications.
📘 T3 Stack Tutorial: 1017897100294....
🤖 SaaS I'm Building: www.icongenera...
💬 Discord: / discord
🔔 Newsletter: newsletter.web...
📁 GitHub: github.com/web...
📺 Twitch: / webdevcody
🤖 Website: webdevcody.com
🐦 Twitter: / webdevcody

Пікірлер: 60
@TedMosby-fk5gj
@TedMosby-fk5gj Жыл бұрын
I implemented this in my app Cody! When i logged the times using the cache, vs without, it was at least 80 percent faster. Devs like you and Josh Tried Coding are a blessing, teaching us advanced topic to implement in our projects.
@insensibility
@insensibility Жыл бұрын
Grats on sponsorship!
@iukeay
@iukeay Жыл бұрын
Legit!
@i3looi2
@i3looi2 Ай бұрын
Keep in mind, this is always dependent on what kind of data you deliver from database. Example1: if you deliver a list of blog posts (which basically a new post appears once/day) .. this is perfect scenario ! But you still have to do update-hooks (for cases where a post was removed; so it does not ghost for another 24h inside the redis cache) Exemple2: if you deliver messages from a roomchat (which basically can change < 1/s depending on how many users there are in the room) .. this is useless to cache. Also, most modern databases already have a caching layer in place. So, IMO , for most use cases , redis is obsolete and just another thing to take care of because adds to project complexity.
@joshtriedcoding
@joshtriedcoding Жыл бұрын
You do custom thumbnails now! Super interesting topic, thanks for sharing. Got a good experience with upstash as well, very handy for serverless
@WebDevCody
@WebDevCody Жыл бұрын
I usually only do thumbnails for my sponsored videos, but I may try doing them for all videos if they start improving click through rate
@TheEchinox
@TheEchinox Жыл бұрын
If you keep this up, you're gonna become the most important tech/eng youtuber out there. No doubt. Keep it up!
@WebDevCody
@WebDevCody Жыл бұрын
thanks I appreciate it
@emmanuelezeagwula7436
@emmanuelezeagwula7436 Жыл бұрын
I love that you get straight to the point
@eshw23
@eshw23 Жыл бұрын
Insanely helpful man, im definately going to add redis for my saas
@DrifterXx22
@DrifterXx22 Жыл бұрын
heya Cody! this is a good thumbnail for the video! keep up the good work!
@WebDevCody
@WebDevCody Жыл бұрын
thanks, I can make decent thumbnails, and I have a couple more coming soon to test out how they perform
@sumitwadhwa8823
@sumitwadhwa8823 Жыл бұрын
redis on a remote server that I need to reach out to every time my api is hit, bugs me. why?
@jmaicaaan
@jmaicaaan Жыл бұрын
Thank you for this great tutorial! I would like to ask how would you handle invalidation or returning the data if there's like pagination involved? Do you set the cache key as the composite of "domainId" + pagination options like limit and page? (eg: post_page1_limit25)
@martinthomas8955
@martinthomas8955 Жыл бұрын
What I don't understand is if cache exists for the user and you return that instead, at what point will they get the latest data if they are only getting the outdated cached data returned?
@WebDevCody
@WebDevCody Жыл бұрын
You can set a timer to expire it. If you need the latest data for users every request then don’t use a cache
@martinthomas8955
@martinthomas8955 Жыл бұрын
@@WebDevCody ah that sounds interesting. Thanks that clears it up.
@SonAyoD
@SonAyoD Жыл бұрын
I need to take a look at this. Thanks
@Arthurk346
@Arthurk346 6 ай бұрын
I used to have Django REST with Redis caching and our Redis was making a copy of its db to a disk. And suddenly we ran out of storage and the API didn't work anymore lol
@hasaniqbal233
@hasaniqbal233 Жыл бұрын
Hey Cody, are you going to continue the Mantine course platform series?
@WebDevCody
@WebDevCody Жыл бұрын
Absolutely, ijust needed to get a couple videos out first
@hasaniqbal233
@hasaniqbal233 Жыл бұрын
@@WebDevCody Great! Will be waiting eagerly :)
@abubakar-emumba
@abubakar-emumba Жыл бұрын
Hi, I need guidance around what tools and technologies are expected from a 3 years experienced frontend (react.js) developer.
@streamocu2929
@streamocu2929 Жыл бұрын
love your content... thank you
@ricardomilos857
@ricardomilos857 7 ай бұрын
Good example, thanks
@StephenHodgkiss
@StephenHodgkiss Жыл бұрын
Hi Cody, do you have any ideas how to set the expires' value on the Javscript Fetch calls ?
@StephenHodgkiss
@StephenHodgkiss Жыл бұрын
It's ok, I figured it out but looks like an extra call is needed as below that sets it to 60 secs: const response = await fetch(cacheEndpoint + "/expire/" + cacheType + '/60', { headers: { Authorization: "Bearer " + cacheBearer, }, });
@27sosite73
@27sosite73 9 ай бұрын
thank you, mate!
@ibrahimmohammed3484
@ibrahimmohammed3484 Жыл бұрын
I've a question, why do we need trpc or an end point and not just use prisma client directly on our server component? or do we still need to have an endpoint?
@WebDevCody
@WebDevCody Жыл бұрын
You could add your database calls directly inside your react server components if you want. I’d at least add one layer of abstraction
@parkerrex
@parkerrex 5 ай бұрын
This is a great video
@shadowplay1211
@shadowplay1211 Жыл бұрын
Is making a local cache manager based on local object or map will be a good idea? Or using redis will be better approach for the best performance?
@WebDevCody
@WebDevCody Жыл бұрын
that will work, but it will not work well when doing serverless since every lambda would has it's own cache. If you have a single VM that hosts your application, then yeah that might work, but redis has a lot of built in features that will make everything much easier as you grow
@shadowplay1211
@shadowplay1211 Жыл бұрын
@@WebDevCody thanks!
@supersteez5316
@supersteez5316 Жыл бұрын
@@shadowplay1211 In-App memory caches can get weird too. Usually when you query from a redis cache, and you make a change to the object returned, it doesn't affect the store, but in-app memory stores, e.g. an object, depending on the implementation can actually update the object in the store. Just a heads up.
@divyanshurawat2422
@divyanshurawat2422 10 ай бұрын
Will this work this much faster in production also ?
@WebDevCody
@WebDevCody 10 ай бұрын
yeah usually caching is something you'd add to a production system to try and improve load time of data that doesn't change often
@TheIpicon
@TheIpicon Жыл бұрын
honestly this is seems a bit of an overkill, if you use Redis just to cache for 10 seconds, you have this already built in in the Next framework, those are called `Segment Config Options`. Which you can cache your api request, without any 3rd party providers and without spending more money on them :)(P.S and it will be faster)
@TheIpicon
@TheIpicon Жыл бұрын
It's not like I'm against Redis, I just think the example wasn't good enough can the edge case you presented have already built it solutions. I use Redis to cache stuff that regular API router caching can't do. Like user specific data or secret stuff
@WebDevCody
@WebDevCody Жыл бұрын
using redis gives you more control I'd say. For example, let's say you cache these comments for 5 minutes for users, BUT you want to invalidate the cache when a new user posts a comment. Correct me if I'm wrong, but if you just let next / vercel cache your api request, you have to wait the full 5 minutes and can not invalidate.
@TheIpicon
@TheIpicon Жыл бұрын
@@WebDevCody I think you’re right, great point!🙏
@animegeek-011
@animegeek-011 Жыл бұрын
Thanks React Query.
@jeremey__
@jeremey__ Жыл бұрын
I just use redis as my primary db.
@OmgImAlexis
@OmgImAlexis Жыл бұрын
This seems less like a reason to use a cache and more of a reason to find out why your query is taking so damn long.
@WebDevCody
@WebDevCody Жыл бұрын
Yes, this was a simple example, but at some point you can't improve the query anymore. I've seen big queries with many joins take seconds before and you're left with little options for optimizing the query.
@abdulrahmanalsabagh3334
@abdulrahmanalsabagh3334 Жыл бұрын
Very nice
@bram1712
@bram1712 Жыл бұрын
Liked the video still one thing trigged me and that was the else when it was not needed since your if always returns the else would not be needed
@WebDevCody
@WebDevCody Жыл бұрын
it'll be ok, an else statement isn't that bad
@larryd9577
@larryd9577 11 ай бұрын
Caching is not the answer to poor database schema.
@parlor3115
@parlor3115 Жыл бұрын
Or you could cache the data on disk like a pleb and force everyone working for you to agree even though you just said that the table is going to have 100 rows at most and it's an app used by like 200 people a day max.
@WebDevCody
@WebDevCody Жыл бұрын
That works for a service deployed to a vm and not on edge or serverless
@parlor3115
@parlor3115 Жыл бұрын
@@WebDevCody Yeah, that too
@SeibertSwirl
@SeibertSwirl Жыл бұрын
Good job babe!!!!
@indrajeetgiri8099
@indrajeetgiri8099 Жыл бұрын
I Don't Understand Why You Wrote false && cache Inside An If Statement You Can Directly Write if(cache) Instead If There Is An Cache Result
@WebDevCody
@WebDevCody Жыл бұрын
Did you watch the video?
@xenmods
@xenmods 5 ай бұрын
POV: me when i think im too smart
@thelaitas
@thelaitas Жыл бұрын
[0]
You might not need useEffect() ...
21:45
Academind
Рет қаралды 161 М.
Why you probably do not need useEffect
10:14
Web Dev Cody
Рет қаралды 24 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 18 МЛН
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 36 МЛН
Deep Dive into HTTP Caching: cache-control, no-cache, no-store, max-age, ETag and etc.
21:28
Do you REALLY need SSR?
18:15
Theo - t3․gg
Рет қаралды 171 М.
Devlog #11- How to make your DB fast by using Caching
8:34
Superthread
Рет қаралды 16 М.
How does Caching on the Backend work? (System Design Fundamentals)
22:45
Software Developer Diaries
Рет қаралды 37 М.
Is Computer Science still worth it?
20:08
NeetCodeIO
Рет қаралды 238 М.
This is why understanding database concurrency control is important
9:05
This is the best way to protect your APIs
9:25
Web Dev Cody
Рет қаралды 92 М.
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35
This is the Only Right Way to Write React clean-code - SOLID
18:23
Redis Crash Course
27:31
Web Dev Simplified
Рет қаралды 626 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 18 МЛН