Website load speed optimization is necessary because of two reasons. First, the faster loading site, the greater the likelihood that the visitor will get a positive impression of the visit and will not leave it immediately, tired of waiting, when the page of the site will be displayed. Second, Google and other search engines into consideration website load speed as one of their criteria, when evaluate sites take. Describes how to optimize website load speed via data compress, step by step setup instructions for Apache http server and configuration directives for mod_deflate. То же самое по русски.
Website load speed optimization via data compress
When the page loads, http server can transmit to user's browser the following data types:
- a HTML text file with the content of the page.
Cascading Style Sheets (CSS) text files with the instructions how and where to display the page elements.
- files containing images or video in special formats.
The first three types of data can be significantly reduced due to compression. And their loading time can be significantly reduced respectively. The image files are already compressed using specialized algorithms. Therefore any attempt to compress them further will not bring any positive results.
My experience shows, that the amount of transmitted data can be reduced by 1/3 or more due to compression or even more, depending on the number of images per page.
There are a lot of different services in the Internet, by which one can analyze the website load speed. I prefer to use two of them. Google PageSpeed Insights and Pingdom Website Speed Test. The second (Fig. 1) outputs as test result excellent visual chart. Where can be clearly seen how much and which types of files is loaded when the page is displayed. Also how long takes a transfer of each fileand its size (Fig. 2). Usually, a chart is much larger. Here is a small piece only.
In the settings one can select a place from which the speed will be measured the speed. To obtain the most reliable results is better to make several tests. With the Google service one can get some good advices how to improve website load speed.
Setting Apache to send compressing data
Web site load speed optimization is done by load and setup mod_deflate module. Next, I will describe how to configure Apache to compress transmitted text files. As a result, Web server Apache will send all text files of these types compressed. If these settings cause any problems, the scope of mod_deflate activity can be limited by directives <Directory> ... </ Directory>.
- Create a secure connection to the server via ssh.
- Became a superuser
- Compression is performed by mod_deflate module. One has to be sure that mod_deflate module is present in the Apache shared modules folder. In Redhat (CentOs) Linux all Apache shared modules should be in the directory /etc/httpd/modules or /chroot/httpd/etc/httpd/modules if http server is chrooted. The module is called mod_deflate.so.
- Changing to the folder /chroot/httpd/etc/httpd/conf/ or /etc/httpd/conf/
- Using text editor vi, vi shall make some changes in the main Apache configuration file:
Find the instructions for downloading Apache modules and uncomment mod_deflate. Should be as it is shown on fig.3. Now Apache will load the module after rereading its configuration file.
- Go down and just before ### Section 3: Virtual Hosts copy and pastethe following text:
This is the standard setting for mod_deflate to compress text files transferred Apache to the visitor's browser. The marked lines are required because some content management systems (CMS), for example WordPress, add some service information after the file type extension (clearly seen in Fig. 2) and mod_deflate directives can not recognize text files to compress.
- Thai is it. Check everything ones more and close editor vi.
- Give Apache command to reread its configuration files:
- Repeat website load speed tests again.
We can see that the page size and page load speed significantly improved.
So we are after 10 minutes of hard work have significantly reduced the website load speed due to compression of text files.
To reduce the size of images, and thus the total time, when browser load them, it is necessary to reduce the size and quality to the To reduce the image size, and thus the time of loading, one should reduce the size and quality to the minimum necessary.
Described why and how to optimize website load speed via data compress. Step by step setup instructions for Apache http server to compress transferring data is given.