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
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!
xcache, eAccelerator, APC
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
Source: https://habr.com/ru/post/19691/
All Articles