“use cache” NextJS’s latest take on data caching

  Рет қаралды 11,962

Jack Herrington

Jack Herrington

Күн бұрын

Пікірлер: 61
@EpilefRodriguez
@EpilefRodriguez Ай бұрын
Thank you for taking the time to share your expertise-it's greatly appreciated!
@jamesbotwina8744
@jamesbotwina8744 Ай бұрын
Thanks!
@bernardyamoah1284
@bernardyamoah1284 Ай бұрын
Finally. Been waiting for this demo
@ashleytwo
@ashleytwo Ай бұрын
Thanks for this clear and detailed explanation
@frostmichael8360
@frostmichael8360 Ай бұрын
This sharing deserves a lot of visibility, thk you !
@katanaut
@katanaut Ай бұрын
Thanks Jack. We love you.
@mavenwander2374
@mavenwander2374 Ай бұрын
Nothing beats Pages Router caching. So clear and simple.
@kamilkacperek91
@kamilkacperek91 Ай бұрын
Honestly, the standard, non experimental version feels more intuitive for me.
@feldinho
@feldinho Ай бұрын
What's the easiest way to tell fetch to always honor the cache control headers from the API? Would that be ergonomic when using API routes? As a backend guy, it feels more intuitive to let the data owner (the API) tell for how long it should be cached.
@ibrahimblahblahyapyap
@ibrahimblahblahyapyap 26 күн бұрын
Jack, how do you get your Terminal @3:31 to look so bloody awesome?
@JoeBoo532
@JoeBoo532 Ай бұрын
Hi, are you planing on doing black Friday deal on your next js pro course ? :)
@DaviLimadeMedeiros
@DaviLimadeMedeiros Ай бұрын
It'd be nice if the ProNextJS course mentioned had a deep diver section on Middleware, e.g. setting cookie on request (not response) is not trivial and not documented
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd 19 күн бұрын
Thank you so much for the video
@prashlovessamosa
@prashlovessamosa Ай бұрын
Thanks this is so helpful
@mortezatourani7772
@mortezatourani7772 Ай бұрын
Like always enjoy the content.
@UnderstandingCode
@UnderstandingCode Ай бұрын
Awesome video!
@irfansaeedkhan7242
@irfansaeedkhan7242 Ай бұрын
thanks for sharing
@azure346
@azure346 Ай бұрын
What a great video ⚡
@rijkvanwel
@rijkvanwel Ай бұрын
Honestly, of late it feels there is no one at the wheel at Vercel in terms of API design. What a mess. Great explanation though
@astralking6162
@astralking6162 Ай бұрын
As i know, pages router had a thing like on-demand ISR, was a cool feature, i was implementing it to my project)
@jherr
@jherr Ай бұрын
Again though, the ISR granularity is a whole page.
@astralking6162
@astralking6162 Ай бұрын
@@jherr Yes, but with on-demand ISR there was no problem. that the product was updated from the admin panel, but it has not yet been updated on the site, since revalidate is set to 60, so for another 60 seconds the product will have outdated information, but with on-demand ISR you could set revalidate to 24 hours and not worry that the product will not be updated, because as soon as the product was updated, a request was made to the product page and it was immediately updated)
@jherr
@jherr Ай бұрын
@@astralking6162 But with ISR you can't control what data on the page is cached at what level. You could send along cache control headers from the API. But if you're doing ISR with server functions those don't have persistent fetch cache. So you'll always be updating all the data at the fastest SLA.
@mainakdas5819
@mainakdas5819 Ай бұрын
Random thought, suppose I have a endpoint that query CMS to get 10 items and query backend to get the price of available 8 items. Now I’ve to merge and filter both the API to get the data ans price of those 8 items only. How do you cache that scenario?
@umarjawhar8
@umarjawhar8 Ай бұрын
great video.
@ShamunkhatriEC
@ShamunkhatriEC 21 күн бұрын
Really good video but what about the client-side data caching? I wanted data caching for at least a specific time. like if I move between routes it should not recall that API again instead show the cached data. I have basic implementation of react query but seems like it is not working out. even explicitly mentioned staleTime property. If you/anyone here know how to do this then let me know
@creatorsremose
@creatorsremose Ай бұрын
Where does requestTime come from? Is that a Next augmentation?
@jherr
@jherr Ай бұрын
No. It’s returned from the API.
@belgarat0
@belgarat0 Ай бұрын
In my app i have tons of data fetching use cases(around 100), do i need to actually place 'use cache' and the timer on every single one?
@codefinity
@codefinity Ай бұрын
🤔 you can keep all in a single ‘lib’ ‘fetchers’ file and pop the directive at the 🔝❔ But, that would apply same caching behavior for all!
@feldinho
@feldinho Ай бұрын
Out of curiosity, how do you do it currently?
@funkjoker
@funkjoker Ай бұрын
Is this kinda PPR from aside?
@jherr
@jherr Ай бұрын
Maybe? I'd have to think about that for a bit.
@MrZiyak99
@MrZiyak99 Ай бұрын
you technically could wrap the cached components in suspense as well correct? it’s just not mandated cause the loading speed would be really fast?
@jherr
@jherr Ай бұрын
Yeah, absolutely.
@SaltyRain1
@SaltyRain1 25 күн бұрын
@@jherr Is it a good practice to always wrap server components that are asynchronous with suspense, even that they are cached. Or it is overwhelming? No clear explanation about that in the official docs
@jherr
@jherr 25 күн бұрын
@@SaltyRain1 I can't say for sure. But it just falls back onto the semantics of Suspense regardless of the whether it's cached because the cache might not hit. So do you want the render to block on that component or not, in the case of a cache miss. That's the question.
@tririfandani1876
@tririfandani1876 Ай бұрын
we need 1 more explanation, the react built in `cache` experimental function
@PeterSahanaya
@PeterSahanaya Ай бұрын
hey jack, is the caching with "use cache" works on vps? not just on vercel
@jherr
@jherr Ай бұрын
Yes. Caching works on VPS.
@adityaanuragi6916
@adityaanuragi6916 Ай бұрын
​@@jherr VPS? (sry I'm noob)
@jherr
@jherr Ай бұрын
@ no worries. Virtual Private Server. Basically a box on the internet that you install on and go. Really he means any non-Vercel deployment.
@adityaanuragi6916
@adityaanuragi6916 Ай бұрын
@jherr like EC2? (thx for da help)
@jherr
@jherr Ай бұрын
@ yes. EC2 or ECS or EKS or just a $4.99/mo hosting site.
@couragic
@couragic Ай бұрын
4:35 Prices are getting higher even in study projects 😢😊
@CanisLatransMedia
@CanisLatransMedia Ай бұрын
Is it me or Jacks lips are always not synced properly 😅 Content good as always tho!
@hamdaniash-siddiq5021
@hamdaniash-siddiq5021 Ай бұрын
well, anything that includes so called 'cache" is something to be aware of. Its a trade between speed and server workload.. Cahing !== optimization.
@dzigizord6567
@dzigizord6567 Ай бұрын
whoever pushed for "use cache" api should be fired. why in the world would you use magic strings for anything. magic strings that influence how infra behaves no less. using normal functions were not cool enough?
@adityaanuragi6916
@adityaanuragi6916 Ай бұрын
I've never used next before, but a directive seems like an absurd way of going about it Why not just a function?
@codefinity
@codefinity Ай бұрын
Directives have 🫘 there and even JS ‘use strict’ from back in the day. Not that 🧐. If you don’t 👍🏾, don’t use it.
@codefinity
@codefinity Ай бұрын
@@adityaanuragi6916Maybe use the tech for s bit first before 💩-posting and/or hating on it.
@feldinho
@feldinho Ай бұрын
@@codefinity It was a bad idea back then, too.
@TianYuanEX
@TianYuanEX Ай бұрын
Just use tanstack; infinitely better DX with far less gotchas and black box stuff in it...
@amershboul9107
@amershboul9107 Ай бұрын
you are the best !
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Next.js App Router Caching: Explained!
25:22
Vercel
Рет қаралды 109 М.
Introduction to Payload - The open-source Next.js backend
13:29
Is Next.js 15 any good? "use cache" API first look
8:16
Beyond Fireship
Рет қаралды 133 М.
This Folder Structure Makes Me 100% More Productive
24:36
Web Dev Simplified
Рет қаралды 118 М.
Tanstack Start vs NextJS - Server Functions Battle
16:02
Jack Herrington
Рет қаралды 21 М.
Why I don't use React-Query and tRPC in Next.js
18:58
ByteGrad
Рет қаралды 102 М.
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 143 М.
This magic hack makes Next.js possible
28:02
Theo - t3․gg
Рет қаралды 55 М.
React 19 STABLE - I Can't Believe They Changed This
11:18
ByteGrad
Рет қаралды 37 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН