Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I add an expires header just for pngs, and the ico file?

share|improve this question
up vote 2 down vote accepted

Use the ExpiresByType directive of mod_expires. Docs here.

ExpiresActive On

# expire after a month
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
share|improve this answer

Example (for the htaccess file):

# Cache the following content for 1 month (4 Weeks)
<FilesMatch "\.(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control "max-age=2419200, public"
share|improve this answer
Why is it Cache-Control and not ExpiresByType? – powtac Jun 11 '12 at 6:02
Both can be done, its about the target: (Target Files by Extension -> FilesMatch) ; (Target Files by MIME Type -> ExpiresByType). It is often easier to use a extension target rather then a MIME type. So if somebody messed up with the MIME config on the server, the filetype target is still working ;-). – BastianW Jun 26 '12 at 21:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.