Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Add caching files with service worker #4

Open
vasco-santos opened this issue May 9, 2018 · 3 comments
Open

Add caching files with service worker #4

vasco-santos opened this issue May 9, 2018 · 3 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community

Comments

@vasco-santos
Copy link
Member

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

@vasco-santos vasco-santos added kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community labels May 9, 2018
@fsdiogo
Copy link
Contributor

fsdiogo commented May 9, 2018

What if a file is cached but isn't available in IPFS anymore?

Just wondering what is the best approach to something like this 🤔

@linonetwo
Copy link

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:

  1. Can we just add ipfs node's repo to cache? (Cache seems to have no limit in desktop browsers though you will be warned if it's getting huge)
  2. Can we send a notification to the user if the object we returned is outdated? By doing so: Besides respondWith cache, we fetching the object from ipfs, and compare it with the cache.

@linonetwo
Copy link

Article about caching stream https://zeit.co/blog/streaming-server-rendering-at-spectrum

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community
Projects
None yet
Development

No branches or pull requests

3 participants