Check and enable Gzip text compression in Joomla 4
How to test website speed and check if Gzip compression is being used. Then enable Gzip in Joomla 4 global configuration and Nginx web server.
What is Gzip text compression and why should you enable it?
Gzip is used to compress text on websites which can make web pages load faster. Text on the page is compressed on the web server and transferred to the client browser where it is displayed. Most modern browsers support Gzip compression.
Gzip reduces the size of data that is transferred between the web server and client web browser
Check Gzip compression
You can check your website Gzip compression using Google PageSpeed Insights
https://pagespeed.web.dev
In this example, testing the website with Google PageSpeed Insights shows the Mobile performance isn't great, with a score of 77.
The PageSpeed test results also show that we can improve the website performance by enabling Gzip text compression.
Enable Gzip compression in Joomla
System - Global Configuration - Server
Gzip Page Compression: Yes
Save & Close
Enable Gzip compression in Nginx web server
Edit the main nginx config filenano /etc/nginx/nginx.conf
# gzip compression gzip on; gzip_comp_level 6; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
Check nginx confignginx -t
Reload nginxservice nginx restart
Test Website speed after enabling Gzip compression
Running PageSpeed insights again, the performance score for the mobile version of the website has now improved to 88
Check web server is serving content using Gzip
You can use Chrome Developer tools to check if your web server is serving content using Gzip.
In this example, we've loaded the web sites robots.txt file to check if Gzip is being used.
Under response headers, you can see content-encoding: gzip which means the web server is compressing text with Gzip.
References:
by Author
Chrome Developer Docs - Enable text compression
https://web.dev/uses-text-compression
Nginx Docs - Compression and Decompression
https://docs.nginx.com/nginx/admin-guide/web-server/compression
Comments