Forum Moderators: phranque

Message Too Old, No Replies

compression - apache style

         

surrealillusions

10:13 pm on Jun 30, 2010 (gmt 0)

10+ Year Member



Hi all,

After some tips to do with http compression.

Got some different type of sites.

The first type is more image heavy, or at least one particular image is a bit large - a png image which im struggling to reduce in filesize. So wondering if doing compression server side can help speed up the download times overall and would help in loading that image quicker.

The 2nd type is a wordpress site, and has numerous plugins, flash and javascript built into it. I've looked into this a little bit, and seen and tried wp-cache and wp-http compression or something. but it didn't seem to work. Is there anything that could be done to help speed it up?

The sites all run Apache (hence been posted in this forum), and have access to .htaccess, but not the server directly.

Would deflate offer advantages over gzip or vica versa? Would doing PHP tricks help at all, such as this:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>


Any help and tips would be appreciated.

:)

lammert

11:21 am on Jul 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PNG images are already compressed and adding an extra compression to it won't give you a much smaller size. A PNG file can have several different formats with different number of colors etc, and for the same image, a different format might give a significant reduction in file size. There are PNG optimizers available which try all possible PNG file types for a given image file and reduce it to the minimum size available. You might try such an optimizer.

Wordpress is easier to compress. JS, CSS and HTML files can often be easily reduced by 80% of the original size. To keep things clean and have an easy upgrade between Wordpress versions, I wouldn't mess too much with the PHP source code.

I have the following line in the httpd.conf for a Wordpress based site to do the compression. It should also work in the .htaccess file.

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css


Note that this directive is available starting at Apache version 2.0.33, and that it is deprecated, but still working in Apache 2.2.