Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
This is a small post about what Gzip compression is.
Basically, Gzip is a compression method that makes files/data smaller in size and there by let it travel faster over networks. This compression allows web servers to send smaller files to the requested users increasing the page load speed. The HTTP protocol has the ebility to gzip data. But zipping the data makes the server do additional work. The browser will be unzipping the files. Text files, like JS, CSS and HTML are best compressed by Gzip.
How does Gzip compression work?
Gzip locates similar strings in a text file (say Javascript, CSS or HTML) and replaces those strings temporarily to make the file size smaller. This information is passed as meta data to the browser to understand for decompressing files. CSS and HTML has many strings that come repeating, that is why Gzip is very effective in the text content compression and not very effective in image compression.
How to enable Gzip compression in my server?
For apache servers you need to enable mod_deflate module and use the following code in .htaccess file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml </IfModule> |
Need help enabling Gzip compression? Contact us here!