How can I add an expires header just for pngs, and the ico file?
Asked
Active
Viewed 1,624 times
2 Answers
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
-
1Why is it `Cache-Control` and not `ExpiresByType`? – powtac Jun 11 '12 at 06:02
-
3Both 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