Chrome显示高速缓存存储使用率高 [英] Chrome shows high cache storage use

查看:134
本文介绍了Chrome显示高速缓存存储使用率高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我意识到具有特定内容长度N的存储图像或脚本实际上占用了高速缓存存储器中的5N-10N空间时,我一直在分析复杂应用程序的高速缓存存储器使用.

I have been analyzing the cache storage use of complex application, when I realized that the stored image or script with certain content-length N actually takes 5N-10N space in the cache storage.

请考虑以下示例:我正在通过服务工作者从OpenStreetMap请求图像,并将其存储在缓存中.缓存中仅存储一幅图像. Chrome版本是最新版本(版本65.0.3325.146(正式版本)(64位)).

Consider this sample: I am requesting image from OpenStreetMap via service worker and storing it in cache. There is only one image stored in cache. The Chrome version is the latest one (Version 65.0.3325.146 (Official Build) (64-bit)).

这是刷新后的高速缓存存储视图:

This is the view of cache storage after refresh:

这是清除缓存"选项卡的视图:

This is the view of clear cache tab:

因此,问题在于大小为6.4KB的图像实际上占用了高速缓存存储13.8MB.我想念什么吗?

So, the problem is that the image which has the size of 6.4KB actually takes 13.8MB of cache storage. Am I missing something?

可以在 https://googlechrome.github.io/上看到该示例.样本/服务工作者/基本/-少于10KB的脚本几乎占据了50KB的缓存存储空间.

The live example can be seen at https://googlechrome.github.io/samples/service-worker/basic/ - less than 10KB of scripts occupy almost 50KB of cache storage.

因此,问题是:当通过服务工作者缓存文件时,它们所占用的空间会显着增加吗?我同意实际请求的权重比实际响应的权重大,但不是 10倍.

So, the question is: how comes that when files are cached via service workers the space that they occupy significantly increases? I agree that the actual request weights more that actual response, but not 10 times more.

可能有用的链接:

  1. Chrome开发工具显示了较高的缓存存储利用率
  2. 服务人员问题
  3. https://bugs.chromium.org/p/chromium/issues/detail?id = 795134
  1. Chrome dev tools showing high cache storage utilisation
  2. Service Worker issues
  3. https://bugs.chromium.org/p/chromium/issues/detail?id=795134

推荐答案

在OSM切片的情况下,高缓存使用率来自不透明的请求.

In the case of OSM tiles, the high cache usage comes from opaque requests.

当您缓存另一个域中的内容时,只能缓存它,而不能以任何方式查看其内容.这使请求变得不透明.您不能摆弄代码中的内容,只能缓存它,这是一个黑匣子.为了避免信息泄漏,浏览器在缓存资源时实施填充.因此,据报告一张100kb的图像占用了7mb的缓存,并且实际报告的大小因浏览器而异.

When you cache something from another domain, you are only allowed to cache it and not see the contents in any way. This makes the request opaque. You cannot fiddle with the contents in your code, only cache it, it's a black box. To avoid information leakage browsers implement padding when they cache the resource. For this reason an image of 100kb is reported to take 7mb of your cache, and the actual reported size differs from browser to browser.

这仅意味着在抛出超出配额的异常之前,您将能够在SW逻辑中缓存少得多的不透明请求.所有缓存的请求-即使实际上很小-都会在缓存中占用大量(填充的)空间,以避免信息泄漏.

This only means you will be able to cache a lot less opaque requests in the SW logic before a quota exceeded exception will be thrown. All of the cached requests – even if very small actually – take lots of (padded) space in the cache to avoid information leakage.

在第二种情况下,我认为这是一个错误.

In the second case I think it's a bug.

这篇关于Chrome显示高速缓存存储使用率高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆