Implement caching using the Cache API
Cache API seems like a great fit and a decent fix for #3 (closed). It could easily-ish be implemented as a Samizdat plugin. Global changes that would need to be implemented are:
-
make sure plugins are actually run one after another (right now it's only the first registered plugin that is used) -
make sure the stash()
method of aSamizdatPlugin
can be registered to be run always after a successfulfetch()
Once these are done, the cache
plugin could be set-up to handle fetch()
after the gun+ipfs
in case of error, and automagically stash()
new content to local cache in case of content being successfully fetched via HTTPS or gun+ifps
.
Eventually cache.fetch()
could be run before any other plugins to display cached content while newer stuff is being fetched, but that would require additional changes in how we deal with things (namely, we would need to be able to re-fetch content that has already successfully been "fetched" by the cache
plugin). This would probably require some magic outside the service worker itself ("oh, this content was fetched using cache
plugin, let's try re-fetching it using any other method").