Repository navigation
Keep the newest unread articles on the device for offline reading - #4
Merged
Merged
Conversation
The service worker now syncs offline copies whenever a logged-in page opens online. It reads /offline/articles (the newest unread articles with a readable copy, 30 by default, set under Settings), fetches each reader page that is new or has changed along with its stored images and the built CSS and JS, and deletes anything no longer listed, so archiving or deleting an article removes its copy at the next sync. Offline, a kept article opens as normal with a notice that it is the saved copy, and any other page falls back to an offline page listing what is available. Reading progress made offline is held in localStorage and sent when the connection returns. Pages are still fetched from the network first, so online behaviour is unchanged. Nothing stays on the device after logging out: the logout form clears the copies before it submits, the response sends Clear-Site-Data, and a sync that finds the session gone deletes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014DPvSBmPyHN2QVmXsQQVKe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The installed app now keeps the newest unread articles, with their stored images, on each device, so they can be read without a connection.
How it works
GET /offline/articleslists what to keep: the newest unread articles that have a readable copy (Settings → Articles kept for offline reading, 30 by default, 0 for none). Each entry has the reader URL, a version that changes whenever the page would, and the stored images the article uses.public/sw.jssyncs whenever a logged-in page opens online (at most every 30 seconds). It fetches new or changed reader pages, their stored images and the built CSS/JS they load, and deletes anything no longer listed. Archiving or deleting an article removes its copy at the next sync.offline.html, which now lists the saved articles (viaoffline.js, a plain file so it runs under any CSP).Logging out
Nothing stays on the device after logout:
Clear-Site-Data: "cache", "storage";Testing
OfflineReadingTest: auth, selection and ordering, the limit and 0, image extraction, versioning, the setting on the page, the sync marker on logged-in pages only, the logout header, and thatsw.jsasks for the route the app serves.php artisan serve, with the browser offline and the server stopped (Playwright's offline mode doesn't reach service-worker requests):/and/archivefall back to the offline list;Generated by Claude Code