Welcome Guest | Login

Caching of Images

I'm looking for a way to cache my images; basically making sure that they are not reloaded every time the page is loaded. I added the following code

<FilesMatch "\.(jpg|jpg|png|gif|ico|swf)$">
Header set Cache-Control "max-age=7200,public"
</FilesMatch>


to the .htaccess in my public directory but that didn't help. Any ideas what is going wrong?

2008-03-01 02:49 PM

You can try putting the entries mentioned in the following link to your .htaccess file.
http://dean.edwards.name/my/flicker.html

Do let us know how it goes..

2008-03-01 04:07 PM

Regards,
Rahul
I put the following entries into the .htaccess

ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A7200
ExpiresByType image/jpeg A7200
ExpiresByType image/jpg A7200
ExpiresByType image/png A7200
#ExpiresByType text/css A3600
#ExpiresByType text/js A3600


Nothing happens with only those entries. If I put additionally

LoadModule expires_module modules/mod_expires.so

then I'm getting a Server Configuration problem as reply. Any idea?

2008-03-02 01:56 AM

I've moved Expires entries to your Virtual host now. Please see if this helped. You can avoid the line LoadModule expires_module modules/mod_expires.so from your .htaccess file.

2008-03-02 06:52 AM

Just to make sure I'm understanding you correctly: You have activated the module mod_expires but I can still configure the caching behavior from public_html/.htaccess. If so - that doesn't work yet. Images are still not cached. Thanks a lot for your help.

2008-03-02 06:59 AM

I have edited the vhost entries for your domain (in apache configuartion file) and put the following entries there.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A7200
ExpiresByType image/jpeg A7200
ExpiresByType image/jpg A7200
ExpiresByType image/png A7200
</IfModule>

Do check and let me know if things are working as you had expected..

2008-03-03 12:07 AM

Regards,
Rahul
Hi Rahul,
Sorry for the slow reply. No this didn't do the trick.

sam

2008-03-04 01:12 PM

Hi Sam,

Please note that mod_expire is compiled as a static module. i.e we have "mod_expire.c"  with apache.

In that case the entries in .htaccess file itself should have worked for you. Also we had copied the .htaccess entries to the apache vhost of your domain for apache to fetch these directives directly.

Also FYI "mod_expires.so" is not existing as the 'expire module' is statically compiled with apache. i.e "mod_expire.c"

Also the following link will provide you more details about the apache directives used for mod_expire available with apache 2.x
http://httpd.apache.org/docs/2.0/mod/mod_expires.html

It is strange that it didn't work out for you. Can you please post us a ticket indicating us how exactly you tested the working from your end.

2008-03-06 02:18 PM

Regards,
Rahul

Hello Guest! In order to post you must be an active client with us, please log in or sign up.