为什么Chrome缓存的请求需要时间? [英] Why chrome cached requests are taking time?

查看:167
本文介绍了为什么Chrome缓存的请求需要时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使Chrome在网络标签中缓存静态文件(JS,图片等),这些文件也需要一段时间,如下图所示。 p>

尽可能多的缓存文件在0ms内加载。有人可以告诉我,即使文件是从缓存中加载,为什么他们加载在> 0ms?

,看到Chrome花费时间下载资源(即使它们来自缓存)看起来很奇怪。这不是从您看到的Web服务器上下载的时间。相反,我相信这是从本地数据库缓存中下载的时间。

检索任何数据都会涉及一定数量的成本。这些资源基本上存储在Chrome的数据库中,要检索数据需要查询,这不是即时的。除了在表中查找数据之外,可能还有一些处理将正确的数据推送到内存中,因为数据的存储方式并不完全如此。它可能被压缩,并且解压缩数据可能是一个缓慢的过程。



您可以在网络标签中看到,虽然看起来花费0毫秒来检索一些资源,当你看到Timings标签时,你会发现它实际上是向下舍入的。例如,尽管它在网格中显示0毫秒,但我在下面的请求中看到了0.08毫秒的停顿和0.02毫秒的下载。 $ b a>



更新:



扩展对高速缓存和网页的检索时间似乎有影响,特别是那些将内容注入页面的内容。 Adblock似乎是我延迟的原因 - 上面的解释仍然适用于其余部分。


Even though Chrome is caching static files (JS, images, etc.,) in the Network tab, these files are taking sometime as shown in the below picture.

Where as many of the cached files are loading in just 0ms. Can someone please tell me even though the files are loading from cache, why are they loading in >0ms?

解决方案

At first glance, it does look quite strange to see Chrome spending time downloading resources even though they are coming from the cache. It's not the time spent downloading from a web server you're seeing. Rather, I believe it is the time spent downloading from a local database cache.

The retrieval of any data has some amount of cost involved. The resources are essentially stored in a database in Chrome, and to retrieve data requires a lookup, which is not instant. As well as looking up the data in a table, there is likely some processing involved to push the correct data into memory, since the data is not stored exactly how it is going to be used. It is likely to be compressed, and decompressing data can be a slow process.

You can see in the Network tab that, although it appears to take 0 ms to retrieve some resources, when you look at the Timings tab, you will see that it is actually rounded down. For example, I see both 0.08 ms stalled and 0.02 ms download in the request below, despite it showing 0 ms in the grid.

Update:

I looked further into this and found that Chrome Extensions seem to have an effect on the retrieval times from both the cache and the web, particularly ones that inject content into the page. Adblock seems to be the cause of some delay for me - explanation above still very much applies for the rest.

这篇关于为什么Chrome缓存的请求需要时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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