Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does chrome Content Download take longer for cached resoures?

I am trying to make the page speed as fast as possible. The problem is that I have one file in particular that takes a long time to download (even if the size is 0 -> loaded from cache)

Here is how it looks without cache (first load):

without cache

And with cache:

with cache

I agree that the time has dropped by almost 50%, but why do I have a Content Download time from my local cache higher than the one from the server?

NOTE:

I am not sure if the times are explained the same in Safari, but it doesn't seem to take that long to get the file there.

Image from Safari Network tab:

enter image description here

like image 299
cuzzea Avatar asked Jul 20 '16 12:07

cuzzea


1 Answers

After running tests on several projects and without any code or further breakdown of the content downloaded processes, here is the conclusion I've reached.

System threads set a priority level for each process they are assigned. When a file is stored in the cache then the download performance is, for the most part, dependent on the performance of the machine. If threads are bogged down then it can result in a slower content download than a download from a server. However, a download from a server is typically slower because of all of the processes involved in contacting, requesting, receiving and handling the download.

The advantage of cache is easily seen when handling slow connections and/or large files. For example, if there's 10+ seconds of waiting due to a slow connection then it's not ideal to load the full page more than once. It would take an incredibly slow system to justify sending that page twice.

Since browser cache removes the send/receive process, it is faster but it doesn't remove load times entirely. In this case, it happens to yield a higher load time in one category.

Side note: It seems odd to classify a file as content downloaded when reading it from the cache but it seems to be consistent amongst all of the projects I tested.

like image 151
sellc Avatar answered Nov 15 '22 05:11

sellc