Open vasco-santos opened 6 years ago
What if a file is cached but isn't available in IPFS anymore?
Just wondering what is the best approach to something like this 🤔
Caching small file is easy, just get link.size
and if size is smaller than a threshold, we add it to cache.
We can get link.size
here.
I have another two thought:
respondWith
cache, we fetching the object from ipfs, and compare it with the cache.Article about caching stream https://zeit.co/blog/streaming-server-rendering-at-spectrum
We will have improvements in the time for getting files if we cache them using the service worker. In this context, the service worker would start by verifying if the file is already stored in the cache. If it is stored there, it can be returned immediately. Otherwise, it should use the running IPFS node, in order to get the file.
It is also important pointing out that, as we intend to support all types of files (consequently, different sizes), some of them may not be the best candidates for being cached. This way, it is necessary to decide a good criterion for caching a file.
Reference: https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker