Hello, I have a question related to the use of cache in Next.js apps using Supabase. I usually use Supabase storage for 2 things: profile pictures and user's videos. I only save 1 pfp per user and i assume they won't be changed frequently. Videos are posted mostly daily and are never changed. My goal is to optimize the caching as much as possible. I use versioned timestamped Supabase Storage paths meaning whenever someone changes his pfp, browser detects a new URL so the pfps get updated and shown immediately. In my next.js code, whenever someone wants to read the pfp or video, he triggers a createSignedUrl that gets passed to the image/video component that downloads and caches the file. One of my questions is this: whenever the refresh happens, is the new signed url created causing the old url and old cache to go stale and new file gets redownloaded even tho it is the same file? My goal would be that all images and videos get cached on the first load for the user and that that cache is used forever so i decrease the load on bandwidth. But with my current understanding, if 2 signed urls point to the same file, browser still treats them as 2 different files, meaning on each refresh a new video is downloaded and cache is basically just never used? Basically would we create a new cache on every refresh but never actually use it since on every refresh we create new signed url? Or is my understanding completely wrong. If my thinking is correct, what is the good way of caching stuff and using the cache to it's fully potential. One of the things that occurred to me is saving the saved URL in the db and basically reusing the same url for everyone checking out that user ( for example create a function getOrUpdateSignedUrl that checks if the saved url is valid in the db, if yes pass it to component if not generate new one (with like 1 year caching duration)? Any help is welcome
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.