Virtual Brain Online Logo

Bookmark: Root \ Apache \ Guide on how to set expire headers for static content with Apache.

Guide on how to set expire headers for static content with Apache.


Last Updated: 2010-12-31

There is no need to reload static content very often. Images, css or javascript don't change very often so why should the visitor download them more then once?

You can configure Apache to send special headers for specific file types. This requires mod_expire which should have come with your apache installation.
Google and Yahoo! suggest expiration dates of one year for static content.

The settings below can be used in a .htaccess file or your main/vhost configuration.

 ExpiresActive On
ExpiresByType text/css "access plus 365 days"
ExpiresByType image/png "access plus 365 days"
ExpiresByType image/jpeg "access plus 365 days"
ExpiresByType image/gif "access plus 365 days"
ExpiresByType text/javascript "access plus 365 days"
ExpiresByType application/javascript "access plus 365 days"
ExpiresByType application/x-javascript "access plus 365 days”

Then issue a reload with /etc/init.d/httpd reload or /etc/rc.d/httpd reload
and head over to WebpageTest.org to see if you could optimize other things.

And here is the manual for mod_expire Apache.org - mod_expires

 

No Comments yet .....

 

Add Your Comment:

Note: All posts require administrator approval. Please allow 24 hours for message approval.

Name:
E-Mail:
Title
Plain text only, less then 65 000 characters.

Do you have a dog?

Please answer the question above and type the answer into the text box below.