But, what are the file types that ExpiresDefault will work on ?
As you’ve stated, “the rest”. Any responses that are not covered by the mime-types stated in the preceding ExpiresByType
directives are covered by the ExpiresDefault
directive.
So, from the directives you posted, this will include HTML (text/html
), JS (application/javascript
), CSS (text/css
) and anything else you are serving.
Are php files also included here ?
Well, that depends what mime-type your PHP files are being served with.
Ordinarily, your PHP files probably default to a text/html
mime-type since you often serve HTML content from PHP files (by default). In which case, your ExpiresDefault
directive will include these responses, since text/html
is not covered by the specific ExpiresByType
directives.
However, PHP can potentially serve anything. Your PHP file could generate a JPEG image, in which case it should be served with a image/jpeg
mime-type (in the Content-Type
HTTP response header). In this case, the ExpiresByType image/jpeg ...
directive will cover this response and ExpiresDefault
will not apply.
Aside:
ExpiresDefault "access plus 2 months"
The plus
keyword is entirely optional. It is just syntactic sugar, to make it more readable.
So, include it or not – it is up to you. But, as with everything, it is important to be consistent. Include it OR don’t include it; don’t mix.
ExpiresByType image/jpg "access 1 years"
ExpiresByType image/jpeg "access 1 year"
You don’t need both of these. Your server is (or “should be”) responding with only one or the other mime-type for JPEG images. It “should be” image/jpeg
, which is the official mime-type. However, you could have a “buggy” script that thinks otherwise.
Check the Content-Type
HTTP response header for the mime-type that is being served. That is the only one you need to target.