📜 ⬆️ ⬇️

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 am sure that all this is true 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, top to bottom).
All links at the bottom of the post





')
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 your html is given in less than 1 second - I think it’s too early to think about code optimization)
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: 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.

upd: On a tip Comrade. Chapaev - “And you can also collect all the interface pictures in one - ImageBundles ”

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)

Here's a way to put js and css in one file:
 <! - / *
 function t () {}
 <! - * /
 <! - body {background-color: Aqua;  }
Below is a link with details.

By the way, here on the habr ran the script combine that packs and compresses css and js


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?
We put \ turn on mod_deflate or mod_gzip for apache and that's it! all your content will be compressed automatically (almost :)).
(This statement is correct only if you have access to the settings of Apache)
We look and compare rice. 3 and Fig. 6. (first request)
in one case 22kb and in another 6kb. almost 4 times!


3. Do not forget about php accelerators

xcache, eAccelerator, APC

Small yes removed ©

4. Do not give customers a 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:
manual
separate subdomain for statics (eg i.zoza.ru )
pros:
• confidence that everything will work as it worked (the Apache will continue to receive direct requests)
• easy setup
minuses:
• you need 2 ip (one for apache and one for nginx, both on port 80, because some admins cut everything that is not port 80)
• you need to edit the templates and set the path to the subdomain

Option 2:
like a front end
manual
pros:
• 1 ip address on different ports
• change nothing in the templates
minuses:
• many resources (apache also has a second server in addition)
• environment variables can “lie”. (eg for apache the client's ip address will be the address of nginx, but it is treated)

3 option:
as the primary (single) web server
pros:
• we clean the Apache absolutely (it is necessary less server storage)
• 1 ip address
• change nothing in the templates
minuses:
• some things, sharpened only under the Apache, will not work


I’m sure that I missed a lot of things and didn’t finish, but already “many letters”. So ask in the comments - I will answer.

advertising :
www.eaccelerator.net
rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
drupal.org/project/javascript_aggregator
blogs.msdn.com/shivap/archive/2007/05/01/combine-css-with-js-and-make-it-into-a-single-download.aspx
sysoev.ru/nginx
csssprites.com
www.drupal.ru/node/8304
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 elsewhere - I haven’t come out with a snout of karma. :)
Transferred to web development. thanks for the karma! :)

UPD: PEOPLE !!! HUMANS !!! This post will be useful to those who are even able to think
for those to whom these things are not yet familiar, but he wants to know.
I gave here a start for the search, so to speak, “spawned the necessary quivers”. That person did not know that there is such a thing as php acceleration - I typed xcache or eAccelerator in Google and that's it ... already in the know.
Or nginx config - yes, there are plenty of articles on this topic in nete.
Or mod_deflate.

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


All Articles