AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml </Location> That should effectively compress all html, plain, xml, and css files.
I want to set an expiration of one month in the future for all my cache-able content. Apache mod_expires will do the job nicely. Again in my httpd.conf file I had and entry for LoadModule expires_module modules/mod_expires.so
.
Then in I created a file conf.d/expires.conf
and placed the following code in there. <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access" ExpiresByType text/html "access" ExpiresByType text/xml "access" ExpiresByType text/css "access plus 1 month" ExpiresByType text/plain "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType application/pdf "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/x-icon "access plus 1 month" ExpiresByType video/x-flv "access plus 1 month" ExpiresByType video/quicktime "access plus 1 month" </IfModule>
This will enable the expires module, then set the default expires to ‘access’ or ‘right now’. You can tweak it to your liking, but the following types of content have expiration date of 1 month from the time the browsers first sees the content.
You want to scale your JPEG images down to as small as possible. Some of my images were way too big and I could shave huge amounts of data with virtually no image loss by reducing my JPG images.
I created a script that uses the jpegtran program found on Linux machines. I created the following bash script optimize.sh
that will take a folder of JPG images, copy them to another folder called new-opt-jpegs
and then compress them.
` #!/bin/bash
mkdir new-opt-jpegs
for filename in $( ls $1/ )
do
jpegtran -opt $1/$filename > new-opt-jpegs/$filename
done;
You would use the script like
optimize.sh images/`. This will take all the JPGs in ‘images’, compress them, then copy them to a folder called ‘new-opt-jpegs’.