D
D
DoubleWish2015-06-26 14:08:33
PHP
DoubleWish, 2015-06-26 14:08:33

Images on the site are periodically not loaded, why?

Hello! From time to time, pictures on the site stop loading, while from different computers from the site everything is loaded in different ways - for someone everything is ok, for someone not. Such problems began to appear after the creation of the CNC on the site (well, or before they were simply not even noticed).
In network in a smoking browser:
147256a2027841e6ab2a5f0131dbf9f7.jpg
In a normal browser:
ddef62aa3abf4d7cbc5ebb6c800a4cc0.jpg
However, this disappears over time. It happens that the page thinks from 5 to 25 seconds before loading, and sometimes everything is on the fly. What could be the cause of this pain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2015-06-26
@xtreme

Pending is waiting. If the smoker has Chrome - then he is limited to 6 simultaneous connections to one resource. You have established a connection, received a page and the browser starts loading the statics. And judging by the browser of the "non-smoker" - you have small pictures there, and you need to establish a connection for each file. With a limit of 6 connections, if you have something slowing down from above, the rest will smoke until the queue is freed.
I turn on the telepathic helmet ...
One of the options is to combine small pictures into sprites and load them in one connection, displaying the right sections in the right places using CSS. (Google PageSpeed ​​will tell you the same)
The second, as a half measure, is to use the cache of the client's browsers so as not to load images from the server every time. But the first time you still have to load them from the page anyway.
Further, apparently, you either cut the speed of access to the web server, or the server frankly slows down. Loading an 80KB image in a second is a long time.
I would venture to suggest that you have Apache as your web server. In this case, I recommend moving it, for example, to 127.0.0.1:80, and in front of it, on the same server, plug nginx with a simple config on the external interface:

server {
  listen 192.168.0.1:80;
  server_name my-super-puper-project;
  
  location ~ ^.+\.(jpg|png) {
    root /home/www/your-project-name;
    expires 1d;
  }
  location / {
    proxy_pass http://127.0.0.1:80;
  }
}

In this case, images (jpg|png) will be given by lightweight nginx without apache, which will significantly unload your server, and everything else (including CNC links) will go to apache. If your css and js are also served directly from the disk, and are not dynamically generated for each request, like crazy, you can include them in the config for pictures.
If the network is in order, the browser will receive static files much faster, which means that the Pending time will also decrease, which will favorably affect performance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question