-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Cache resources through localStorage/indexedDB on the backend side #415
Comments
On the other hand, there are some drawbacks :
And some things to pay attention to :
And things to do, that are the same if we choose #414 :
|
Do you mean something different from cache.js, which is the current cache layer I'm using? I tried to put most of the code in there, but what remains in app.js are mostly the intercept hooks. Maybe more of the code can be pushed to cache.js?
When I was developing this, Firefox didn't support indexedDB from the file:/// protocol. However, looking at it now, it seems that it does. I even put a comment in the code about this! It's actually the main reason I made the cache support localStorage as a fallback. Seems that's been fixed recently in FF. Internet Explorer supports indexedDB only in localhost mode, but doesn't support any cache protocol in file:// protocol, hence the fallback to memory cache.
Indeed, localStorage can't, AFAIK, store BLOBs. But would we really want to cache images? It would only be useful if someone is reloading the same page. The only objects I can foresee us needing to cache are stylesheets and JavaScript, because these are likely to be the same ZIM-wide.
The cache only supports CSS currently and a copy of the HTML retrieved from the ZIM for the current page. The latter is overwritten for every page visited. CSS is the same ZIM-wide, so we'd want to retain indefinitely, until the user empties the cache on purpose. User can empty the cache using the radio button, then all elements are cleared.
They are currently separated by a database key that is specific to each ZIM. Even if the CSS file is the same in two different ZIMs, it will be stored under its own ZIM-specific key. You can inspect the content of the cache using the F12 tools Here is an example from Edge: |
I'd like to keep this issue open for one main reason: as mentioned, I need to implement (have already implemented in another branch) indexedDB caching for jQuery mode, to use in Kiwix JS Windows. I want to implement it in a way that fits fully with the Kiwix JS codebase, and that needs me to make it work on current master with #556. Once that is working properly in a Kiwix JS branch, I'll close this issue. I'm not expecting that what I implement will be merged in Kiwix JS. |
Just to say that I have ported all changes in #556, and all latest changes to master to the branch Persist-cache-in-localStorage, and am therefore closing this issue. To be clear, this has been implemented as a basis for a Version 2.0 of Kiwix JS Windows (Version 1.0 is close, and will use the existing codebase). I do not intend to implement this in Kiwix JS. For info, this branch implements a similar caching strategy to #556 in jQuery mode, using a separate module called
Included in this implementation is extraction and running of JavaScript in jQuery mode. It is able to run simple JS, and can also run PhET experiments, but it cannot run React JS interfaces such as those provided by Gutenberg ZIMs. |
This would be an alternative to #414.
@Jaifroid has already done some hard work in branch https://github.com/kiwix/kiwix-js/tree/Persist-cache-in-localStorage
We have to decide if we prefer to implement this or #414.
An advantage for this solution is that it could probably be made to work the same for both jQuery and ServiceWorker modes.
The text was updated successfully, but these errors were encountered: