Enable Gzip Compress on WordPress with WP-Cache 2.x

»»»Enable Gzip Compress on WordPress with WP-Cache 2.x
WP-Cache is a page caching system plugin for WordPress blog that cache WordPress pages during the first load or after a page expired, and store each WordPress page in a static HTML file which in turn used to serve future requests. This process of web server serving the HTML pages directly from the file rather than building the page again by loading and compiling the whole PHP code, and retrieving the necessary data from the database where there is any page request significantly reduces the resource needed to run a responsive and fast website. Meanwhile, Gzip compression is an option provided by WordPress that allows web server to serve the articles in compressed format if request by supported web browser, reducing bandwidth used and improving performance.

If you install WP-Cache version 2.0 or 2.1, you will be requested to turn off or disable Gzip compression in Options -> Reading tab. Although WP-Cache2 is fast enough, however, you can still try to enable the Gzip compression to further speed up the web server, improve the overall performance of network and website, and save the network bandwidth, by using the following trick. The hack allows Gzip compression to be used with WP-Cache system, by making WP-Cache compress the page articles, instead of WordPress.

To turn on Gzip compression of web page while using WP-Cache 2, simply edit the wp-cache-phase1.php which is located in the WP-Cache plug-in folder inside the Plugins directory with text editor such as vi:

Add the following line:

if ( extension_loaded('zlib') ) ob_start('ob_gzhandler');

Before this line:

foreach ($meta-»headers as $header) {

Note that you still should not turn on or enable the Gzip compress article in WordPress. If you do so, WP-Cache will not work.

By |2016-12-09T08:40:21+00:00December 9th, 2016|Categories: Web Publishing|Tags: |3 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.