mw.loader.store: decline to store items > 100 kB
authorOri Livneh <ori@wikimedia.org>
Fri, 5 Jun 2015 00:06:49 +0000 (17:06 -0700)
committerOri Livneh <ori@wikimedia.org>
Fri, 5 Jun 2015 00:34:26 +0000 (17:34 -0700)
commit6132865a06cd4654ec7c08b8443caa96a9683fd4
tree482022cfd2b12a4519abd11ac2ceb006875f5737
parentf93a0be92c601535d310feccd6579b6635bf49b7
mw.loader.store: decline to store items > 100 kB

If the length of the string representation of a module exceeds 100,000
characters, decline to store it in localStorage, due to bug T66721.
(While it is true that string length !== byte length, the skew introduced by
counting multi-byte characters as single bytes is not important enough to merit
the use of $.byteLength).

Based on my analysis, the modules that would be ineligible for caching in local
storage under the new schema are:

- ext.visualEditor.core (624 kB)
- oojs-ui (179 kB)
- oojs-ui.styles.icons (132 kB)

To fix this bug, it is not enough to not store new items; we must also ensure
that any old values cached prior to the introduction of a limit are purged. So
update mw.loader.store#prune to do that, too.

Bug: T66721
Change-Id: Ie45467fc0b2db7cc283f30626af7d587da24bd90
resources/src/mediawiki/mediawiki.js