Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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"
</FilesMatch>
share|improve this answer
    
Why is it Cache-Control and not ExpiresByType? –  powtac Jun 11 '12 at 6:02
2  
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

 
discard

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.