To analyze the speed of the site, we used the PageSpeed Insights service. This service checks the site for errors, page opening speed, and search engine optimization of your site. In this guide, we will increase the speed of the site by enabling compression and enabling a cache for static files on the nginx web server.
1. Enable gzip compression and cache settings.
Let's add the following settings to the server section of your host configuration file.
server {
...
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# text/html is always compressed by gzip module
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 7d;
}
...
}
1.1 Let's check the configuration for errors
nginx -t
1.2 Restart the service
service nginx restart
Make sure your site is working correctly in your browser and check your PageSpeed Insights metrics again. Depending on the structure on different sites, the site speed indicator will increase by 15-20%.
No Comments Yet