Best way to cache a inifinite scroll view of videos

Hi, Im working on a app with a infinite scrollable video similar to Tiktok or instagram reels. I initially thought it would be a good idea to cache videos in the file system but after reading this post it seems like it is not recommended to cache videos on the file system: https://forums.developer.apple.com/forums/thread/649810#:~:text=If%20the%20videos%20can%20be%20reasonably%20cached%20in%20RAM%20then%20we%20would%20recommend%20that.%20Regularly%20caching%20video%20to%20disk%20contributes%20to%20NAND%20wear

The reason I am hesitant to cache videos to memory is because this will add up pretty quickly and increase memory pressure for my app.

After seeing the amount of documents and data storage that instagram stores, its obvious they are caching videos on the file system. So I was wondering what is the updated best practice for caching for these kind of apps?

Hello @dwally, thank you for your post. Have you considered using AVQueuePlayer to manage a queue of player items?

Hi @Engineer, thanks for answering. Would I be able to use a AVQueuePlayer with multiple AVPlayer layers (video views), with each player item corresponding to a different view? At first glance It did not seem like this is how AVQueuePlayer was intended to be used.

So what I want to do is:

when I get the list of URLs I want to play, I manually cache the first 2 seconds of all those videos. And resume downloading the rest of the content once the user is ready to watch it. Im wondering if it is best to store the cached videos in memory or on the device.

Best way to cache a inifinite scroll view of videos
 
 
Q