How to enable gzip compression (Apache mod_deflate) in cPanel
To enable the gzip compression for your site, follow the steps:
- Go to yourdomain.com/cpanel and log in
- Look for Optimize Website entry (SOFTWARE cPanel section)
- Here you have 3 options:
–Disabled – which will disable the compression
–Compress All Content – with this option all content will be compressed
–Compress the specified MIME types – here, you will be able to input only certain MIME file types. - So, choose the second option and click the Update Settings button. A confirmation message will appear: Website optimization preferences updated. Content compression is now enabled. Content compression is now enabled for all content.
- Your site is using now the gzip compression.
Enable Gzip Compression - Configuration for Nginx and ApacheHow to enable Gzip compression?
Depending on which web server you are using, the method to enable Gzip will vary. The following describes both an Apache Gzip configuration as well as an Nginx Gzip configuration.
Apache Gzip configuration#The following snippet can be added to your
.htaccess
to enable Apache Gzip compression for JavaScript, XML, text, fonts, HTML, and CSS. This list of file types can be modified based on your needs.<IfModule mod_deflate.c> 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/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml </IfModule>
Nginx Gzip configurationFor Nginx users, the following snippet can be added to the configuration file in order to enable Nginx Gzip.gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
Comments
Post a Comment