HTML5 Touch Interface design and development reading notes

Source: Internet
Author: User

Fourth ChapterCreate a cache layer
Memory layer var memorycache={};      var cache_ttl=864000000;      var cache_prefix= "Ti";      function Setcache (mykey,data) {var stamp,obj;      Stamp=date.now ();      obj={Date:stamp, Data:data};      Localstorage Layer Localstorage.setitem (cache_prefix+mykey,json.stringify (obj));      Memorycache[cache_prefix+mykey]=obj;      } console.log (window);      function getcached (MyKey) {var key,obj;      Key=cache_prefix+mykey;      if (Memorycache[key]) {if (Memorycache[key].date-date.now () >cache_ttl) {return false;      } return memorycache[key].data;      } obj=localstorage.getitem (key);      if (obj) {obj=json.parse (obj);      if (Date.now ()-obj.date>cache_ttl) {Localstorage.removeitem (key);      Delete (Memorycache[key]);      return false;      } memorycache[key]=obj;      return obj.data;      }} setcache (' Lilu ', 39);      getcached (' Lilu ');      Console.log (memorycache[' Tililu '); Console.log (LocalSTorage); 


Management Localstorage

Localstorage can store 5MB of content

The following formula calculates whether the Localstorage space is full.


1024*1024*5-unescape (encodeURIComponent (json.stringify (localstorage)). length


App Cache Application Caches

 



CACHE manifest# The date below is a simple# the sure I #file # 2013-03-15r4jquery-1.8.0.min.jsgull-360x 112.jpggull-640x360.jpggull-720x225.jpgfallback:network:*



HTML5 Touch Interface design and development reading notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.