Cache expiration on static images and content with .htaccess

VN:F [1.9.22_1171]
Rating: 4.0/5 (4 votes cast)

One of main thing for all web sites is content caching to improve site performance. Here are few examples how You can achieve this. Set this cache expiration example, which I am using on my content delivery network (CDN) server ME2J.com.

<FilesMatch ".(jpg|png|gif)$">
ExpiresDefault A0
Header set Cache-Control "max-age=0,  no-cache, must-revalidate"
</FilesMatch>

Which mean, that expiration date is in access moment and set headers to 0 values. As You can see, here You can add more filetypes for static content

.htaccess cache expiration code

This example can also speed-up Your webpage just with few lines of code by setting longer expiration time:

ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000

Where A is access time and 2592000=60*60*24*30 or one month.

VN:F [1.9.22_1171]
Rating: 4.0/5 (4 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Cache expiration on static images and content with .htaccess, 4.0 out of 5 based on 4 ratings

You can tray this example,which I am using on my content delivery network (CDN) server ME2J.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>