unicef / carrotjuice2

Front end to resources repo. Defaults to Brazil but will eventually be virus and country agnostic.
1 stars 1 forks source link

Use HTML5 Web Storage for admin polygons #54

Open jetpack opened 8 years ago

jetpack commented 8 years ago

Save admin polygon data on the client-side after the first load so subsequent refreshes are faster.

Requires some versioning scheme so clients don't end up with stale data.

gatoatigrado commented 8 years ago

I think we had talked about only having 5 MB of local storage, and how trying this is thus kinda crazy (it is). But it looks like someone wrote a LZ compression library exactly for this purpose, lz-string,

% node
> var data = require('./data/static-assets/br_topo.json');
> var lz_string = require('lz-string');
> var compressed = lz_string.compress(JSON.stringify(data));
undefined
> compressed.length
294929

that's 294 KB for the TopoJSON file, and it seems reasonably fast. Other performance-related things we can do,