Page MenuHomePhabricator

mobile-html - Article Persistence - [Dev] - Article & Article Resource Caching
Closed, ResolvedPublic

Description

Have an article cache controller that performs the duties of caching an article should a user tap the bookmark icon throughout the app.

  1. Article cache controller will fetch mobile-html & mobile-html-offline-resources and cache the response via FileManager. Remove cache when user toggles bookmark icon off. Keep track of cache via PersistentCacheItem & PersistentCacheGroup Core Data objects, similar to CacheItem & CacheGroup manner that current ImageController uses. Only delete resource if it is not shared by another article. [DONE]
  2. When bookmarking on article screen, we should not be fetching all the resources again, several of them should already be in URLCache.shared because we use Session behind the scenes in SchemeHandler. Dig into why this isn't happening if it isn't. [DONE]
  3. Have SchemeHandler attempt to pull from URLCache.shared for happy path. If nothing comes from URLCache, try fetching with session. If that fails (i.e. connection error), try pulling from persistent cache via Article Cache Controller. [DONE]
  4. Ensure caching process can continue if ArticleViewController is deallocated. [DONE].
  5. Ensure caching process can recover (or database is cleaned out and user is notified) if pieces of the saving fails (i.e. they tap bookmark without a connection, let it try again when a connection restores). In general do an error handling/todo audit on all of this. Only consider an article as saved if it has mobile-html and mobile-html-resources urls cached. [DONE, will add followup task for housekeeper download retrying.]
  6. Make general enough so other things can use this caching system, not just articles. [DONE, stretch goal is we could subclass CacheController and write a StandardCacheController that say, the diffing endpoint could refer to that DiffController hooks into upon fetching.]
  7. Save ETAG in caching and send in the request header so we can lean on caching. [DONE]
  8. Pull from cache on state restoration - it is ok if it is stale as we want them to see data as quickly as possible. [DONE, but we might want a network fallback in case cache is missing somehow]
  9. Set excludeFromBackup when setting up caching directory so that user is in a consistent state when migrating to a new device. [DONE]
  10. When pulling from cache via SchemeHandler, be sure to take full URLRequest as input to consider variant logic. [DONE]

Event Timeline

Tsevener renamed this task from mobile-html - Article Persistence - Add CacheControllers to mobile-html - Article Persistence - [Dev] - Add CacheControllers.Dec 6 2019, 6:09 PM
Tsevener created this task.
LGoto triaged this task as Medium priority.Dec 9 2019, 10:48 PM
LGoto moved this task from Needs Triage to Engineering Backlog on the Wikipedia-iOS-App-Backlog board.
Tsevener renamed this task from mobile-html - Article Persistence - [Dev] - Add CacheControllers to mobile-html - Article Persistence - [Dev] - Article & Article Resource Caching.Jan 7 2020, 3:02 AM
Tsevener updated the task description. (Show Details)
Tsevener updated the task description. (Show Details)
JMinor awarded a token.