By using site services you agree to our Cookies Use. We and our partners operate globally and use cookies, including for analytics, personalisation, and ads.Accept

/Server configuration to speed up the site.

There are many things that affect the page downloading speed. In this post, we will talk about ways to speed up the site work by configuring the hosting.


Gzip compression and caching reduced the amount of transferred data from 3.3 Mb to 1.94 Mb. Compressed HTML of home page weight is 141.71 Kb instead of 939.99 Kb.
Gzip compression and caching reduced the amount of transferred data from 3.3 Mb to 1.94 Mb. Compressed HTML of home page weight is 141.71 Kb instead of 939.99 Kb.

Gzip compression is the process of reducing the weight of a file by using special algorithms. Your server compresses the file and passes it to the user. The user decrypts the compressed file back. Thus, the amount of data transmitted is reduced.

There is a setting to specify the compression level. The higher it is, the less the file weighs, but this creates a load on the server.

You can compress the files preliminary to save server resources on this process.


Caching is the browser's ability to store previously downloaded files in the computer's memory. Therefore, duplicate files are downloaded only once for different pages.

Configure the apache

You need to install and enable the mod_expires, mod_deflate and mod_headers modules.

Next, specify the settings in the virtual host file.

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 5 seconds"
    ExpiresByType image/x-icon "access plus 2592000 seconds"
    ExpiresByType image/jpeg "access plus 2592000 seconds"
    ExpiresByType image/png "access plus 2592000 seconds"
    ExpiresByType image/gif "access plus 2592000 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
    ExpiresByType text/css "access plus 604800 seconds"
    ExpiresByType text/javascript "access plus 216000 seconds"
    ExpiresByType application/javascript "access plus 216000 seconds"
    ExpiresByType application/x-javascript "access plus 216000 seconds"
<IfModule mod_headers.c>
    Header set Cache-Control "public"
FileETag MTime Size

Configure the nginx

These settings need to be entered in the Nginx virtual host file:

# Enable gzip
gzip on;
gzip_comp_level 6;
gzip_types image/svg+xml \
           text/plain text/html \
           text/xml \
           text/css \
           text/javascript \
           application/xml \
           application/xhtml+xml \
           application/rss+xml \
           application/javascript \
           application/x-javascript \
           application/x-font-ttf \
           application/ \
           font/opentype \
           font/ttf \
           font/eot \
gzip_disable "MSIE [1-6]\.";
# Enable etag caching for data
location ~ \.(manifest|appcache|html|xml|json|rss|atom)$ {
    expires -1;
    add_header Cache-Control "public";
    etag on;
# Enable caching for images, icons, video, audio, HTC location
~ \.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
    expires 1W;
    add_header Cache-Control "public";
    etag on;
# Enable caching for CSS and Javascript location
~ \.(css|js|eot|woff2|woff|ttf|otf)$ {
    expires 1y;
    add_header Cache-Control "public";
    etag on;

Always make a backup copy before updating the configuration files.