Enable GZIP output compression on a WordPress Blog

This is a great optimization code for any wordpress blog out there. Some servers might do it automatically, others don’t, in case of doubt just create the code below in the functions.php file and see your bandwidth consumption go down just like your site loading time.

 if(extension_loaded("zlib") && (ini_get("output_handler") != "ob_gzhandler"))
   add_action('wp', create_function('', '@ob_end_clean();@ini_set("zlib.output_compression", 1);'));

Compartilhar:

2 Comentários. Comentar

Lalit
27 de fevereiro de 2013 8:28

Thanks for this little post. this did worked.

i had scanned countless forum posts, adding this code in .htacess, adding that code in some other file . even faced 500 error in process. this worked flawlessly.

Responder
Michael Belk
3 de abril de 2013 23:42

I am not sure what to do with this code, help?

Responder
Comente