Where to store/cache downloaded videos - TikTok clone

I wonder how TikTok/Instagram caches the video so the playing is so smooth. I was thinking about downloading them on a sequence and allow user to skip n video only when n+1 is downloaded. But where should I store/download it? Should I use NACache for that or just save them in app temp with FileManager?

Also some pseudo-code of how to do that with SwiftUI might be very helpful. 🙏🏼

For images, NSCache is a good way, even I think, that all these kinds of apps use a preview Image before the video start.

For large data maybe it's better to download the video and cache it on cachesDirectory using the file manager, writing the data on a file, and then, before fetching from the internet the second time, you can see if you have it on the cachesDirectory. If you'll find the file use its URL to make your logic with it.

Where to store/cache downloaded videos - TikTok clone
 
 
Q