-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWA: Add method for visitors to save pages for offline viewing #201
Comments
Having a user-initiated Save Offline feature is something we considered demonstrating for the PWA plugin, but we haven't yet done so. It's much easier to just cache a page that a user visits, since runtime caching will pick up all the assets that are referenced on the page. One workaround for that would be to load the page in a hidden iframe, which is what Surma did in his Progressive WordPress proof of concept: Two complications for the I suppose there are three use cases here for the content being offline:
The first use case is simpler, as there's nothing the user has to do, there's no UI to incorporate into the theme, and there's no technical complications (the service worker just has to add the responses to the runtime cache). The second use case is more difficult, since you have to proactively iterate over all assets to include in the cache. As opposed to iterating over the DOM as suggested in that article, you can instead use
This is something I was planning to prototype with the PWA plugin when I got a chance. In addition to querying all cached pages in the Cache API, I think the actual titles of the pages should be able to be extracted by reading the |
See https://chrisruppel.com/blog/service-worker-offline-content/
Currently all visited pages are cached (or they should be), up to 50 pages, but the user has no control over which specific pages are cached. We could add a "Save for offline viewing" button to allow users to intentionally download some content. It should probably use a separate cache bucket than the navigation cache so navigation doesn't knock out valid entries, and we should maybe disable the navigation cache to reduce duplicate cached entries.
Could also improve the offline view by listing out available content (or later attempt by same author).
The text was updated successfully, but these errors were encountered: