On your (WordPress) website, you have the option to use Gzip. Gzip is a form of compression, which means that if you use this on your website, the size becomes smaller. As a result, your website loads faster, and you can therefore process more traffic and the user experience as a whole becomes more pleasant.
You enable Gzip compression your WordPress website by following the steps below.
Activating Gzip on a webhosting package
Log in to the control panel and click 'Shared Hosting' in the menu. Next, select your domain below 'Products'.
Next, click 'Advanced' at the top and select 'Performance & Caching'.
Gzip is enabled by clicking the sliding button next to 'GZIP compression'. Once the button is green, GZIP is activated.
Activating Gzip on a VPS
Open your .htaccess file with a text editor and add the following at the top of your .htaccess file:
<IfModule mod_deflate.c> # force deflate for mangled headers # developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ <IfModule mod_setenvif.c> <IfModule mod_headers.c> SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding </IfModule> </IfModule> # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: <IfModule filter_module> FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/html'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/css'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/plain'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/x-component'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/javascript'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/json'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/xhtml+xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/rss+xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/atom+xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/vnd.ms-fontobject'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'image/svg+xml'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'application/x-font-ttf'" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'font/opentype'" FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no </IfModule> <IfModule !mod_filter.c> # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype </IfModule> </IfModule> <IfModule !mod_deflate.c> #Apache deflate module is not defined, active the page compression through PHP ob_gzhandler php_flag output_buffering On php_value output_handler ob_gzhandler </IfModule>
And the following directly after <?php in (wp-)config.php (at the top of the file):
ob_start('ob_gzhandler');
Your wp-config.php fire will look like this at the start:
<?php ob_start('ob_gzhandler'); /** * The base configurations of the WordPress. * * This file has the following configurations: MySQL settings, Table Prefix, * Secret Keys, and ABSPATH. You can find more information by visiting * {@link http://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php} * Codex page. You can get the MySQL settings from your web host.
Save the files and upload them back to your website.
In this article we have explained how to enable GZIP compression on your webhosting package or VPS.
Should you have any questions left regarding this article, do not hesitate to contact our support department. You can reach them via the ‘Contact Us’ button at the bottom of this page.