Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
I'm not sure if this we meant the same thing here, but I was referring to the caching headers that you implement within an API route you created, example with setHeader used in an API route. I genuinely thought that these headers were telling your servers, in my case Vercel's servers, to cache the fetched data on the server every time the fetch() runs. This way no need to store the latest fetched data in a database, but those are still cached and, therefore, immediately available when you want to retrieve (via fetch/axios or SWR/RQ) that data on the client (via fetch/axios or SWR/RQ) because it was already fetched on the server and cached on the server. If the "The fetch() implementation inside your API route does not do anything with those caching headers." What are they for? This means that using an API route is pointless if you don't store your data in a database? Every time you fetch() your API route on the client fetch('../api/user/'), the fetch() implementation inside your API route will have to make its requests from scratch fetch('https://example.com/some-external-endpoint') ? If this is true, there is no point of using an API route as it doesn't reduce the amount of work and waiting time on the client. You can make your life easier by directly fetching the external endpoint on the client...
There is nothing on the server that causes the API route to rerun. In Lee’s examples, he is using the SWR JavaScript library on the client to manage caching and requerying of the API.
Related posts
- Mastering Data Fetching in React: A Comprehensive Guide to SWR
- Building a Blog Subscription and Pusher with AirCode and Resend
- Looking for Minimal portfolio website template
- Torn over personal minimalist aesthetics vs modern web design
- WebDev: Ce ar trebui sa incep sa invat: Next.JS 12 vs Next.JS 13