Cache Filetypes

You can drastically improve your site’s load time and decrease used bandwidth by enabling file caching for specific filetypes.

When a user visits your site for the first time, all filetypes that you specify will be cached in their browser. Then, each subsequent time that same file is used, it will be pulled from the cached file rather than being requested from your server over and over again.

For example, you can cache all the images on your site since they will not be changing, and the same images will not have to be requested from the server multiple times.

You can also set a time limit on how long the filetype should be cached, so if you should update the file at a later date, the existing files will only be cached for so long.

The amount of time you specify to cache a filetype is done in seconds. Convert the timeframe you wish to set into seconds, then use it in your .htaccess file.

For example, the following code will cache images for one month (2,592,000 seconds):

Header set Cache-Control "max-age=2592000"

You can cache all of your static html files for 24 hours:

Header set Cache-Control "max-age=43200"

You may also wish to cache stylesheets and javascript:

Header set Cache-Control "max-age=604800"

You can use any filetype and timeframe you want. Seperate each filetype with a “|”.

Here are some common timeframes to help you get started:

3600 = 1 hour
86400 = 1 day
604800 = 1 week
2419200 = 1 month
29030400 = 1 year (never expires)