2

I have a problem where on page load (after a certain number of .js or .css files) the files are taking way too long to load. At first I thought that the issue must be inside the .js files, but later I realised that the content is irrelevant, I tried deleting the content of the .js files that took too long to load and the issue was still there. I also realised that if I change around the order in which the files are loaded then the one(s) I leave for last are always the one(s) that take very long to load (this load time differs from PC to PC, on mine it's 5-6 seconds, on another one it's 19-20). I'm currently using Apache 2.4 for development and I suspect that the issue must be in the settings somewhere.

You can see the issue here:

image

Any help would be appreciated.

ThoriumBR
  • 5,272
  • 2
  • 23
  • 34
  • Is this on the first load or every page load afterwards? It could be a local PC issue if the cache is being slow. – Nathan C Sep 09 '14 at 12:32
  • How much of that is spent on Connecting / Sending / Waiting / Receiving for the requests that take longer? – Giovanni Tirloni Sep 09 '14 at 12:34
  • @Nathan C: This happen on every page load. The PCs I tested it on are rather new, the issue is definitely not with the hardware (i7/i5, 7200RPM HDD in one of them, the other is deployed on SSD, 16GB/8GB RAM). – barney.balazs Sep 09 '14 at 12:44
  • @gtirloni: Most of the time is spent on waiting (the rest are neglible, only 1-2 ms) – barney.balazs Sep 09 '14 at 12:47

2 Answers2

1

The situation is rather strange. My suggestion is to profile your application client side and try to understand what is going on.

Generally the problem could depend on:

  1. A locally cached content that is very slow to be read, this should not depend on a particular file corruption since the files being slow depend on the sequence you put in the JS referencing.

  2. A rendering problem on the client (though this should not change on the sequence of the referenced items)

  3. A possible problem of parallel transfers on your apache server. This could imply that you have a truckload of files to be taken with different GET operations and Apache cannot serve all of them in parallel. Therefore a serialization could occur with the effects you are experiencing.

  4. Different ways to get the same files, possibly opening another worker on apache (i.e. main page through direct IP to Apache, JS over proxy pointing to the same Apache. And Apache being configured in a single worker scenario (I don't enough information to judge it)

  5. A damn antivirus acting locally which triggers on the browsers loading operations

My advice is to do the following:

  1. Install a profiling tool (my preferred one is to use Firebug)
  2. Profile the application in NET panel
  3. Load the page and see how the items are loaded
  4. Try to check the logs in Apache. For this particular issue, if you are working on a development server, try to increase the logging level to debug. "LogLevel Debug"

At the end of the profiling you will notice which is the cause of serialization of the process.

0

Browsers have a limit of concurrent connections to a domain. That means, browsers won't open additional connections to load further resources until the previous resources have finished loading. This could be one reason for the behavior.

Therefore it is recommended to put all .js code into a single file, and also .css to a single file.

Another possibility is that if this happens on all page loads, the HTTP cache headers might be set so that no caching occurs on the browser side. Therefore the browser loads the resources every time it connects to the page, which also slows down the process.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58