Why chrome cached requests are taking time?
Asked Answered
B

2

8

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.enter image description here

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?

Blubberhead answered 28/6, 2016 at 12:15 Comment(1)
look at this developers.google.com/web/fundamentals/performance/… #3401549Crosseyed
D
5

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.

Not instant

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.

Detached answered 28/6, 2016 at 14:7 Comment(4)
Thanks for the detailed explanation, Gideon.Blubberhead
For me I get 280ms TTFB if I go from Sydney to my server in Amsterdam, or 280ms to go about 7cm from my CPU to memory. If this is true, the world is indeed a strange place.Dolley
@DavidGilbertson Yes, the retrieval from the database/processing can't account for this level of time. Did you try running without any extensions enabled?Detached
Yes, those stats are from Chrome Canary no extensions. It's interesting the difference between say github (which has long TTFB) and stackoverflow (which has very short TTFB) for cached assets.Dolley
M
0

Oddly, timings in Chrome are a bit... quirky... the time is not purely network time. If the JS engine gets blocked somehow, it is included in that total time...

enter image description here

If you hit this issue go to "timeline" tab and record a full timeline.

Mauricemauricio answered 6/10, 2016 at 12:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.