📜 ⬆️ ⬇️

And again about the speed performance of your site

Phew ... finally I decided to write my first post.

In this post I want to tell you about some simple, and at the same time effective ways to speed up the loading of your site.
All methods are based on LAMP + nginx + drupal, but I think that all this rolls for the rest too.
The conversation will be about the first loading of the site, that is, when the client has no cache in the browser.

A few illustrations to which I will refer in the course of the article:
Names are written in altos (from left to right, from top to bottom).
All links at the bottom of the post


picture 1 drawing 2 picture 3

figure 4 figure 5 figure 6
')
The main thing is not the size but the number ©

1. The smaller the number of requests (requests) to your site, the better!

look at pic 3
Time in seconds, this adsl line 2.5Mb
So, what do we have? There are 37 requests and 18 seconds. of time. Lot!
The first request is actually html itself (if <1 sec = do not touch)
then send css, js and pictures
as you can see from the screen, the pictures are given in parallel, but css and js are not !
Conclusion one: Reduce the number of requests for css and js
In the fifth drupal, the css compression chip into one file is a build-in, that is, just go to performance and set it up there.

look rice one
Instead of 9 file requests and 6 seconds. we receive 1 request and 1.5 seconds of time. Not bad… :)
Now turn js.
Download the javascript_aggregator module - instalim, and get the same feature in js for the same js
look rice 6 and see that all our js files now take only 1.5 seconds. instead of the same 6 seconds. Almost good ... :)

It is also possible to add to the number of requests that if you have a lot of similar images on the site (icons, pictograms)
It is worth looking in the direction of css sprites. That is, all these pictures are shoved into 1 file in a row, and then in css for the right place we do offset. As a result, we have 1 query instead of 5-10.

And finally, if you have a digg level site, insert all your css and js inline in html, this will save 2-3 more requests. (Yes, they are not cached, but so much faster. + You can insert them on internal pages when the pictures are already in the cache)


2. Click all given content!

Forget about any ob_start ("ob_gzhandler");

Why bother php and yourself if you can compress all the web server automatically?
Put \ turn on mod_deflate or mod_gzip for apache and that's it! all your content will be compressed automatically (almost :)).
(php compression rolls only if there are no rights to edit the apache)
We look and compare rice. 3 and Fig. 6. (first request)
in one case 22kb and in another 6kb. almost 4 times!

Small yes removed ©

2. Do not give customers static apache!

This monster begins to terribly slow down under heavy loads.
To upload pictures (and the same css, js, flash, etc.) use the nginx web server
There are 3 options for setting it up:
1 option:
separate subdomain for statics

Option 2:
like a front end

3 option:
as the primary (single) web server




advertising :
drupal.org/project/javascript_aggregator
sysoev.ru/nginx
developer.yahoo.com/performance/rules.html
hostingfu.com/article/running-drupal-with-clean-url-on-nginx-or-lighttpd
sittinginoblivion.com/node/251

Ps. I am writing to my personal blog, I can’t go to another place - I didn’t come out with a snout of karma. :)

Source: https://habr.com/ru/post/19647/


All Articles