Persistent Managed Caches with Remix Client Loader

  Рет қаралды 5,065

Remix

5 ай бұрын

Take fine-grained control of your site's user experience by leveraging clientLoader to cache data directly in the browser.
Play with this demo 👉 remix-movies.pages.dev/
Checkout the code 👉 github.com/remix-run/example-movies
00:00 - Previous caching strategies overview
00:46 - Client-side caching with browser storage
04:45 - Demonstration of the persistent cache
06:27 - Inspecting IndexedDB
08:24 - Persistent managed caches review
Learn more at remix.run

Пікірлер: 14
@sayedhasan4102
@sayedhasan4102 5 ай бұрын
7:42 there's a refresh button to show the latest index db data, it's above the first column :)
@kellenbusby
@kellenbusby 5 ай бұрын
Hey great video, Ryan. A really nice demo of clientLoader. I'll have to play around with this. Do you have any plans to make videos or discuss progressive web apps and Remix?
@tedogirma
@tedogirma 5 ай бұрын
this is best feature and it fixs all hydration issue Thanks Rayn also it works with defer mode on clientLoader which is nice 🥂🥂🥂
@yanchesky
@yanchesky 5 ай бұрын
Nice series!
@Greybph
@Greybph 5 ай бұрын
Very cool. Gonna have to rewrite some of my logic using Jotai persistent atoms and implement this pattern with the clientLoader instead.
@akshayaurora
@akshayaurora 3 ай бұрын
Don't we need to worry about invalidating the client side cache?
@RoufaYouakeem
@RoufaYouakeem 5 ай бұрын
React query in client loader to manage the cache for us?
@Callerooo
@Callerooo 5 ай бұрын
Is there some convention when to clear this indexDB? I'm thinking it might become very large if the user clicks on a lot of movies?
@twitchizle
@twitchizle 5 ай бұрын
I wouldnt mind that much,
@HerrSiering
@HerrSiering 5 ай бұрын
MDN says: "The process by which the browser works out how much space to allocate to web data storage and what to delete when that limit is reached is not simple, and differs between browsers." - so my guess would be that the browser takes care of keeping the size in check. And if it then deletes an item because of this, the code falls back to loading it again from the server. And probably another item is removed then? Anyways, nothing to actively care about because the browser takes over that job for you.
@user-ix9wk7vt7w
@user-ix9wk7vt7w 5 ай бұрын
3:50 If Ryan had some defer hooks in serverLoader, what would happen? Can't we let clientLoader to save cache to loaclforage?
@tedogirma
@tedogirma 5 ай бұрын
ya i works fine Here is simple sample i have got ``` export async function clientLoader ({ serverLoader }: ClientLoaderFunctionArgs) { const key = 'received' const cacheData = await localforage.getItem(key) if (cacheData) return { received: cacheData } localforage.setItem(key, serverLoader()) return defer({ received: serverLoader() }) } use trycatch to handle incase if there is issue inside serverLoader ``` And Server Loader is ``` export async function loader () { return db.received.findMany({ take: 15, where: { to: '9153' } }) } ``` also use Suspense and Await inside your tsx file i think this what you need ....
@ceopaludetto
@ceopaludetto Ай бұрын
Probably he need to await the movie aswell, but he checked if has a defer to properly destructure since you cannot destructure a promise let loaderResult = await serverLoader() let movie = await loaderResult.movie
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
Универ. 13 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:07:11
Комедии 2023
Рет қаралды 6 МЛН
💅🏻Айфон vs Андроид🤮
0:20
Бутылочка
Рет қаралды 742 М.
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 55 МЛН
#miniphone
0:16
Miniphone
Рет қаралды 3,7 МЛН