简体   繁体   English

在我的Web应用程序上模拟浏览器缓存

[英]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. 这意味着,例如,我可以以低成本获得页面包含但不通过其他协议通过http请求获得的所有图像。 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. 我希望能够将这些图像(我获得的图像)保存在浏览器的内存(indexDB,applicationCache等)中,然后在渲染页面时不从http而是从我的缓存中加载它们。

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. 注意:1)我更喜欢不需要更改.html和src attr的方法2)我还可以使整个页面前进,不仅是照片,还可以进行一些操作。

any idea's? 有任何想法吗?

You can use PersistJS which abstracts different browser storage capabilities in to a common interface. 您可以使用PersistJS将抽象的浏览器存储功能抽象到一个通用接口中。 Acts like localStorage and has several back-ends (like cookies, flash storage etc.). 行为类似于localStorage,并具有多个后端(例如cookie,闪存等)。 You can store them here and check them out if they exist here. 您可以将它们存储在此处,并检查它们是否存在于此处。

Read this tutorial on html5 cache. 阅读有关html5缓存的本教程 you need to create the cache manifest file and write your images path in the #cache section of manifest file. 您需要创建缓存清单文件,并将图像路径写入清单文件的#cache部分。 put the reference of file in each .html/.htm file header. 将文件引用放在每个.html / .htm文件头中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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