简体   繁体   English

在本地存储中存储JS和CSS有什么意义?

[英]What is the point of storing JS and CSS in localstorage?

While reading Stoyan Stefanov's web performance daybook I have encountered the following: 在阅读Stoyan Stefanov的网络性能日刊时,我遇到了以下问题:

Google and Bing store JavaScript and CSS in localStorage to improve their mobile site performance Google和Bing将JavaScript和CSS存储在localStorage中,以提高其移动网站的性能

and the link to the blog with a description. 以及带有说明的博客链接 Nonetheless I read it (and have reasonable experience working with localstorage), I sill can not understand what is the point of such action. 但是,尽管我读了它(并在使用本地存储方面有合理的经验),但我仍然无法理解这种行为的意义。 In my opinion the browser is already doing a job of caching CSS and JS and there is absolutely no point to store them in localstorage. 在我看来,浏览器已经在缓存CSS和JS了,绝对没有必要将它们存储在localstorage中。

Can anyone explain in simple English what is the reason? 谁能用简单的英语解释原因?

PS In the beginning I thought that may be it has something to do with the size of the cache of mobile browsers, but when I checked I found that they have more then 20Mb of cache which (in my opinion) is pretty enough to make sure that such popular sites like google and bing will have place to be cached. PS首先,我认为这可能与移动浏览器的缓存大小有关,但是当我检查时发现它们的缓存超过20Mb(我认为)足以确保这样像Google和Bing这样的流行网站将有地方可以缓存。

+1, Nice question. +1,很好的问题。 The only reason I can think of is for speed of load time, in those cases were it is no longer stored in the cache. 我能想到的唯一原因是加载时间的速度,在这种情况下,它不再存储在缓存中。 Also, as the post you linked to pointed out, it makes their HTML files a lot smaller ---200kb to39kb is a big difference. 而且,正如您链接到的帖子所指出的那样,它使HTML文件更小了--- 200kb至39kb是一个很大的不同。

EDIT: 编辑:

You asked in what conditions would it no longer be in the cache. 您询问在什么条件下它将不再存在于缓存中。 From my understanding of how the cache works, I believe that the cache size is fixed, so after a while those files would get pushed out to make room for more files. 从我对缓存的工作原理的理解中,我相信缓存的大小是固定的,因此一段时间后,这些文件将被推出以为更多文件腾出空间。 Hope it helps 希望能帮助到你

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

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