Browsers are equipped to serve compressed pages. Most hosts too have mod_gzip or zlib extensions installed to ensure you can avail of these features.
Compression ensures that your browser receives a smaller packet and so you effectively save bandwidth.
WordPress by default also comes with this feature that enables you to compress the webpages and send them to the browser.
You can find it under Options » Reading. Scroll to the bottom where you will find WordPress should compress articles (gzip) if browsers ask for them.
I’ve noticed upto 1 second difference between the loading times of my pages with this checked and unchecked.
After checking this, it is best to analyze your page to see if gzip is infact working or not. For this I use Web Page Analyzer.
In case you do have the above option checked and this is reporting that the files are not compressed, you will need to talk to your host.
Many of us have WP-Cache installed on our WordPress installation. When a page is requested for the first time, WP-Cache creates a cache file for the page. Subsequent requests are served from the cache. This ensures that the page doesn’t need to be recompiled, thus reducing the load on the server.
The problem with WP-Cache is that it doesn’t support GZip encoding. This means, that you need to first uncheck the above option that I talked about. This also means that you’re increasing the load time of your pages as well as consuming more bandwidth.
However, Mark Jaquith and Chris Stormer have found that a minor change in the the code of the plugin can turn on GZip encoding.
All you need to do is find the line
foreach ($meta->headers as $header) {
in wp-cache-phase1.php. This is line 35 in my file.
Just before this line you need to add:
if ( extension_loaded('zlib') ) ob_start('ob_gzhandler');
Now, your file will look like:
if ( extension_loaded('zlib') ) ob_start('ob_gzhandler');
foreach ($meta->headers as $header) {
Save the file and upload it and your set.
You can analyze the page again using the analyzer to check if the files are compressed.
Note that the above option in WordPress has to be disabled, or your pages will be royally messed up!
For those interested, the line of code we added checks if the zlib extension is installed. If it is, then it calls ob_gzhandler which gzips the output buffer and sends it to the browser.
Home






Actually, I’m totally confused about what you asked. Can you explain it in detail?
When a page is not loaded from cache (because it has been expired, or is a new page or …) a line is added to the source of page (after html close tag [/html]) like this:
<!– Dynamic Page Served (once) in 0.493 seconds –>
But when you reload that page in your browser these two lines are added (indicating that page is loaded from cache):
<!– Dynamic Page Served (once) in 0.493 seconds –>
<!– Cached page served by WP-Cache –>
This occurs when WP-Cache is not modified and does not generate compressed pages.
You can check this by viewing html source of any wordpress blog using WP-Cache without compression like WP-Cache creator’s blog at http://mnm.uib.es/gallir/ .
I applied your modifications to my WP-Cache installation and did not see the second state whenever I try to reload the page.
This is what I want to know. Why this does not happen?
You should check in WP-Admin > WP-Cache if the cache pages are being generated or not.
Easiest way is the clean the cache in WP-Admin and then start browsing your site and see if it says that pages are cached.
Nice post but there is a better solution to serve gzip pages without sacrificing CPU power by caching the compressed page once it is generated.
I have explained the required modifications here
The only drawback is that it doesn’t support embedded dynamic PHP functions.