Offline article reading: what to synchronize after reconnecting

An executed retained-copy model: reading permission and expiry, body and media updates, unknown failure and confirmed withdrawal.

A textile metaphor for a retained copy and a restored connection.
A textile metaphor for a retained copy and a restored connection.

A reader saved an article before a journey and opened it without a network connection. Meanwhile, the server changed the text, lost an image or received an editorial withdrawal. The local file still exists. The question extends beyond downloading new bytes: what may be displayed before reconnecting, what must be checked afterward, and when should the old copy be hidden?

For this analysis, I separate server knowledge from reader knowledge. An independent synthetic model using Python 3.12 and SQLite executes a timeline with a logical clock. The canonical example is tools/offline-reading-lab. The 19-transition timeline was rerun separately; 22 unittest methods passed: the original 19 and three regression tests. This is an executed model of local storage decisions; it is not a mobile application, PWA, HTTP cache or synchronization implementation for the current API.

A saved copy has a defined scope

The model's key contains a site, stable article identity, locale and reading policy context. A Ukrainian version on another site or a copy in another context must not accidentally inherit the first record's permission. URLs and titles help open an article but do not establish its identity or current reading rights.

The text has its own revision. A separate version field describes an authoritative decision about the entire copy: availability, offline permission, expiry and media references. Access denial can change version while retaining the same text revision. Checking body revision alone would easily miss that decision.

The model's source is fictional. It explicitly supplies active, withdrawn or denied, a decision version and a policy. This is a proposed teaching envelope rather than an existing endpoint. A real server first needs an agreed contract and a decision about which signals it may disclose.

Offline reading needs explicit policy

Having text in a database does not authorize displaying it. The model requires active state, explicit granted=true, an unexpired local permission and no unresolved validation. Without permission, display is closed. The policy context is synthetic; the model performs no real authentication or granting of rights.

Expiry uses logical time units. With lease_until=20, time 19 still permits display, while 20 does not. This deliberately precise boundary is checked for every reading decision, so delayed cleanup does not extend permission. A separate cleanup operation removes body and references after expiry.

Such a lease limits use of a known permission but cannot announce a future server change. A disconnected reader holding accepted version 1 does not know that the source already reached version 2. Until a new signal arrives, the model may show the old copy within its permission. This approach promises no instant revocation on a disconnected device.

Reconnecting begins with validation

When reading the source again, the client must accept a coherent state. In the scenario, the first text refers to image revision 1. The newer text requires revision 2. The model changes the body and exact media references in one local transaction, while refusing to substitute the old image into the new text.

Synthetic timeline step Client knowledge Display decision
Version 1 saved Text 1, media 1, permission until 20 Complete article
Disconnected, server already changed Client still knows only version 1 Old permitted copy
Version 2 accepted Text 2 requires media 2 Text only under declared policy
Exact media 2 received Body and media references agree Complete article
Request produced no definite state Reason for unavailability unknown Hidden, copy retained
Confirmed withdrawal received Newer decision version, no body Article hidden

Text-only display requires separate fallback=true permission. Without it, missing required media closes display. This may be acceptable for an article whose image is optional illustration. For instructions that cannot be understood without a diagram, the product may choose stricter behavior. The model forces that choice to be named without making it for every article.

Unknown failure does not become deletion

A network error does not prove that an article disappeared. A generic 404 does not identify the cause either: it cannot automatically mean “translation missing,” “access revoked” or “editor deleted the article.” In this scenario, both network failure and generic 404 produce unavailable_unknown.

The model chooses a strict policy after such an attempt: display closes until successful validation, even while the older local lease remains valid. Text stays in the database for a later decision but is not shown. This is a declared product tradeoff rather than the only possible policy for every offline reader.

Successful confirmation of the same authoritative version with the same envelope can clear uncertainty. It neither extends the lease nor creates a new text revision. If expiry already caused logical body cleanup, identical old confirmation does not restore it; a newer agreed state is required. An absent response never silently becomes permission.

A late response cannot restore hidden content

The model considers request responses arriving in reverse order; it does not test actual concurrency. Each new source read therefore receives a local request generation. A response from a previous generation is rejected even when its payload contains a large version number. This protects the client's current selection rather than establishing a global event order.

The second guard is authoritative version within the key. Lower versions are not applied; equal versions with a different envelope conflict. Comparison uses canonical serialization of the exact synthetic schema, while the database stores its digest. After accepted withdrawn or denied state, the model removes body and references but retains the version floor.

Consequently, an old request cannot restore the removed text. Even a current-generation response with an older version is rejected. Republication requires a newer authoritative decision. In the timeline, version 3 withdraws text 2, and version 4 permits it again without inventing another body revision.

Images have their own lifecycle

Bodies and media should not be cleaned through one unconditional file list. An image may belong to several saved articles. Model references contain media identity and exact revision; the separate media record has its own authoritative decision version.

When the image itself is withdrawn, its payload is logically removed. An older media response cannot restore it, while text remains available if fallback is permitted. The fixed Cache.accept processes media updates transactionally before returning for an identical article envelope: a newer withdrawal applies, while stale or conflicting media rolls back all updates. The http_no_store gate remains in force: a duplicate with that prohibition retains no payload. This differs from confirmed withdrawal of the entire article, which closes text regardless of available images.

When only one article is cleaned, a shared payload remains while another local copy still references it. After the final reference disappears, the model removes the payload while retaining media version and digest. This manages logical SQLite records. It proves no physical erasure of database pages, backups, screenshots or other derivative bytes.

Application policy does not cancel HTTP rules

A teaching permission for offline reading must not bypass server cache directives. RFC 9111, section 5.2.2.5, defines no-store: a cache must not retain the relevant request and response for reuse. The model's synthetic flag prevents storing the body, references or media supplied alongside them.

Section 5.2.2.2 requires successful validation before reusing a stale response carrying must-revalidate. The model implements no HTTP age calculations, headers or conditional requests. Its separate http_requires_validation flag conservatively closes offline display. This checks a policy boundary rather than claiming full HTTP cache conformance.

What the executed example showed

Inputs and expected outcomes for all 19 steps were frozen before the first execution. The run saved separate actual decisions and SQLite rows after every transition. Reopening the database confirmed persistence of state and version floor during ordinary local execution. This does not test power loss or distributed synchronization.

Separate tests covered the exact expiry boundary, absent permission, key scopes, late requests, equal-version conflicts, access denial, media revisions and shared references. A synthetic reference-insertion failure tested rollback of body and media changes. On Python 3.12.3 and SQLite 3.45.1, all 22 unittest methods passed: the original 19 and three regression tests. The separate rerun of the 19-transition timeline retained its unchanged expectations; these are not 41 independent test cases.

The tests used no real accounts, network or server responses. Text and image data are short synthetic strings. A successful display decision therefore does not confirm rendering arbitrary HTML, interface accessibility or downloading a real file. Those checks must arrive with a concrete client.

This result refines requirements for a future reader: retain the known text revision, authoritative policy and validation need separately; accept coherent references; avoid inventing failure causes. Native versus web technology, real rights, background downloads, bookmarks and synchronization of user changes remain separate work. The executed model provides tested decision examples for one reading scenario.

  1. Caching The cache key as a contract: site, language, permissions and query parameters
  2. Article Engineering An image as a separate asset: identity, originals, and derivatives
  3. Caching Stale results or errors: choosing a stale-data policy
  4. Architecture HTTP cache and application cache: who refreshes the page?
  5. Platform Engineering Old events arrive later: revisions and asynchronous change ordering

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article