Website load is one factor Google been considered to rank websites in their search engine. The next tutorial explain a step to improve loading time in your website. This step is focusing on gzip encoding and caching, it compress the content from your server to the client browser. The reduced file size is what speeds up loading time. We can use one of three ways to enable gzip encoding, php.ini, .htacess and using PHP.
You would want to check if GZip is enabled on your site using an online tool at GidZip Test. . If you see “NO” for “Web Page compressed?”, then gzip encoding is NOT enabled for your website
1. We can apply gzip compression on Apache level or Server level, simply add the following line anywhere: zlib.output_compression = on.
2. If you want to apply gzip compresion on certain directory in your server, put the following in .htaccess file
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf AddOutputFilterByType DEFLATE font/truetype font/opentype </IfModule>
3. You have WordPress installation. Download your WordPress index.php file from your server root directory. Open it up using your favorite PHP editor. Add the following line just below top php:
ob_start("ob_gzhandler");
This method requires you to manually add that line again after a WordPress upgrade to enable gzip encoding. When upgrading your WordPress, the line you added,
ob_start("ob_gzhandler");
will be removed from index.php