I have used this before;
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "now plus 2 weeks"
// Lots omitted here
</IfModule>
And this;
<IfModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|JPG)$">
Header set Cache-Control "max-age=1209600"
</filesMatch>
// Lots omitted here
</IfModule>
I can set the expires on by content-type and I can set any header I wish by file extension.
But neither of these seem to let you set any header you want by content-type.
I want to set the cache-control header based on the content-type of the response - note that this is not the same as the file extension. I have "friendly URLs" so there is no file extension to be captured by filesMatch
so there is no file extension but the content-type is text/html
.
How can I set the cache-control header for specific content-types?
ExpiresByType
directive does (well, specifically, it sets themax-age
directive of theCache-Control
header, as well as theExpires
header for backward compatibility). However, if you wanted to set "any header" or specific directives in theCache-Control
header then you would need a different method.