» Control cache expire dates using htaccess

If you're running Squid to cache your website, you can use an htaccess file to control what kind of files should be cached, and for how long.

Prerequisites

First you should enable mod_expires, the Apache module that can control the Expire HTTP header in server responses:

a2enmod expires

htaccess

Next create a .htaccess file in your web root, containing:

ExpiresActive On
ExpiresDefault "access plus 4 hours"
ExpiresByType application/javascript A900
ExpiresByType application/x-javascript A900
ExpiresByType text/javascript A900
ExpiresByType text/html A90
ExpiresByType text/xml A90
ExpiresByType text/css A900
ExpiresByType text/plain A62
ExpiresByType image/gif A14400
ExpiresByType image/jpg A14400
ExpiresByType image/jpeg A14400
ExpiresByType image/png A14400
ExpiresByType image/bmp A14400
ExpiresByType application/x-shockwave-flash A3600

And that's it! Play around a bit with the values to suit your needs.

You probably shouldn't follow me


Like this Article?

I'd appreciate it if you leave a comment, spread the word, or consider a small donation


tags: squid, htaccess, virtual host, apache, mod_expires
category: Howto - Webserver
read: 39,368 times

Add Comment

Comments have been automatically closed because of the age of the article. If you need to, you can still contact me on the subject.

Comments

#5. Roch on 21 April 2010

Gravatar.com: Rochgave this a try (im using joom la) didnt get it to work... let me know if theres something different that needs to be done.

#4. Kevin on 07 January 2010

Twitter.com: kvz@ アダルト無料動画: My pleasure :)

#3. アダルト無料動画 on 26 December 2009

Gravatar.com: アダルト無料動画Thank you so much for sharing this great tip.

#2. davarciforum on 14 October 2008

Gravatar.com: davarciforumthanks a lot

#1. sibirya on 28 August 2008

Gravatar.com: sibiryathanks a lot