1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 10:52:43 +01:00
uBlock/src
Raymond Hill 086766a924
Redesign cache storage
In uBO, the "cache storage" is used to save resources which can
be safely discarded, though at the cost of having to fetch or
recompute them again.

Extension storage (browser.storage.local) is now always used as
cache storage backend. This has always been the default for
Chromium-based browsers.

For Firefox-based browsers, IndexedDB was used as backend for
cache storage, with fallback to extension storage when using
Firefox in private mode by default.

Extension storage is reliable since it works in all contexts,
though it may not be the most performant one.

To speed-up loading of resources from extension storage, uBO will
now make use of Cache API storage, which will mirror content of
key assets saved to extension storage. Typically loading resources
from Cache API is faster than loading the same resources from
the extension storage.

Only resources which must be loaded in memory as fast as possible
will make use of the Cache API storage layered on top of the
extension storage.

Compiled filter lists and memory snapshot of filtering engines
(aka "selfies") will be mirrored to the Cache API storage, since
these must be loaded into memory as fast as possible, and reloading
filter lists from their compiled counterpart is a common
operation.

This new design makes it now seamless to work in permanent private
mode for Firefox-based browsers, since extension storage now
always contains cache-related assets.

Support for IndexedDB is removed for the time being, except to
support migration of cached assets the first time uBO runs with
the new cache storage design.

In order to easily support all choices of storage, a new serializer
has been introduced, which is capable of serializing/deserializing
structure-cloneable data to/from a JS string.

Because of this new serializer, JS data structures can be stored
directly from their native representation, and deserialized
directly to their native representation from uBO's point of view,
since the serialization occurs (if needed) only at the storage
interface level.

This new serializer simplifies many code paths where data
structures such as Set, Map, TypedArray, RegExp, etc. had to be
converted in a disparate manner to be able to persist them to
extension storage.

The new serializer supports workers and LZ4 compression. These
can be configured through advanced settings.

With this new layered design, it's possible to introduce more
storage layers if measured as beneficial (i.e. maybe
browser.storage.session)

References:
- https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local
- https://developer.mozilla.org/en-US/docs/Web/API/Cache
- https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
2024-02-26 16:50:11 -05:00
..
_locales Import translation work from https://crowdin.com/project/ublock 2024-02-13 15:36:10 -05:00
css Make the "untrusted sources" warning always visible 2024-02-18 08:00:34 -05:00
img Output scriptlet logging information to the logger 2024-01-25 12:20:38 -05:00
js Redesign cache storage 2024-02-26 16:50:11 -05:00
lib Redesign cache storage 2024-02-26 16:50:11 -05:00
web_accessible_resources Minor code review 2024-02-13 17:52:05 -05:00
1p-filters.html Make the "untrusted sources" warning always visible 2024-02-18 08:00:34 -05:00
3p-filters.html Remove minimum height constraint from "My filters" pane 2024-01-19 11:26:01 -05:00
about.html Patch Unicode country flags with image-based flags 2023-05-20 21:35:52 -04:00
advanced-settings.html Fix cloud storage widget not showing (regression) 2023-04-10 10:03:51 -04:00
asset-viewer.html Convert remaining vAPI.setTimeout to vAPI.defer 2023-04-14 10:26:45 -04:00
background.html [mv3] Add ability to enable/disable filter lists 2022-09-13 17:44:24 -04:00
cloud-ui.html Work toward bringing dark theme closer to a stable release 2022-01-30 18:35:26 -05:00
code-viewer.html Convert remaining vAPI.setTimeout to vAPI.defer 2023-04-14 10:26:45 -04:00
dashboard.html Prevent dashboard from loading at browser launch until ready 2023-03-16 09:17:36 -04:00
devtools.html Remove "Purge all caches" button from "Filter lists" pane 2023-12-13 21:01:51 -05:00
document-blocked.html Fix cloud storage widget not showing (regression) 2023-04-10 10:03:51 -04:00
dyna-rules.html Fix cloud storage widget not showing (regression) 2023-04-10 10:03:51 -04:00
logger-ui.html Fix incorrect built-in filtering expression in logger 2024-02-15 14:03:15 -05:00
no-dashboard.html Code maintenance: replace uDom.js with dom.js 2022-11-12 09:51:22 -05:00
popup-fenix.html Minor HTML/CSS changes 2023-04-27 08:49:45 -04:00
settings.html Fix cloud storage widget not showing (regression) 2023-04-10 10:03:51 -04:00
support.html Isolate DOM inspector layers from page context 2023-12-03 16:21:32 -05:00
whitelist.html Convert remaining vAPI.setTimeout to vAPI.defer 2023-04-14 10:26:45 -04:00