2

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

powtac
  • 639
  • 2
  • 6
  • 19

2 Answers2

4

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>
BastianW
  • 2,868
  • 4
  • 20
  • 34
  • 1
    Why is it `Cache-Control` and not `ExpiresByType`? – powtac Jun 11 '12 at 06:02
  • 3
    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
3

Use the ExpiresByType directive of mod_expires. Docs here.

ExpiresActive On

# expire after a month
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000    
Jeff Snider
  • 3,272
  • 18
  • 17