简体   繁体   中英

simulating browser cache on my web application

so i have a website and i want to build a mechanism to simulate browser cache. meaning, for example i can get, for low cost, all the images that a page contains but not via http request via other protocol. i want to be able to save those images(the one that i got ahead) within the memory of the browser (indexDB,applicationCache etc.) and then when i render the page not to load them from http, but from my cache.

notes: 1) i prefer a way where i dont need to change the .html and src attr 2) i can also get the entire page ahead and not only the photos and maybe make some manipulations.

any idea's?

You can use PersistJS which abstracts different browser storage capabilities in to a common interface. Acts like localStorage and has several back-ends (like cookies, flash storage etc.). You can store them here and check them out if they exist here.

Read this tutorial on html5 cache. you need to create the cache manifest file and write your images path in the #cache section of manifest file. put the reference of file in each .html/.htm file header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM