Skip to content

LocalStorage cache

Mikhail Davydov edited this page Oct 10, 2013 · 3 revisions
  • Flags: cache, cache_async, Property: version

You can store all your in-package modules and lmd itself in localStorage. (Disabled by default)

  1. Set config flag cache: true and add version: your_current_build_version property to your config file then build your LMD package - it will be created in cache mode. If no version - LMD package will run in default mode - without dumping modules
  2. Set config flag cache_async: true to cache require.async() requests in localStorage too
  3. Remove script tag <script src="out/index.production.lmd.js" id="source"></script> with LMD initializer:
<script id="lmd-initializer"
  • id - always lmd-initializer (do not change it)
  • src - path to lmd_initializer.js
  • data-key - localStorage key where all lmd code stored (do not change it)
  • data-version - content in localStorage must match this version
  • data-src - fallback if version do not match or no localStorage or error or no content

See Live example of LS cache

Note: version property from config and from data-version attribute must match to use code from localStorage! Yep! Each time you have to change config file and your html file!

Something went wrong with that request. Please try again.