apachemod-expires

ExpiresByType with both a wildcard and a specific mime type


If I have Apache set to use:

ExpiresByType image/* A3600
ExpiresByType image/png A7200

Presumably, inverting this would make all images cache for one hour because the wildcard is last:

ExpiresByType image/png A7200
ExpiresByType image/* A3600

Images will default to one hour expiry, but will my PNG files be cached for one hour or two? Or to rephrase the question, does mod_expires continue processing rules after it finds the first match? I can't find a definitive answer to this either on SO or in the documentation, or even in examples online. Is this likely to be consistent across HTTPd versions?


Solution

  • I have observed that on Apache 2.4.6

    ExpiresByType image/* A3600
    ExpiresByType image/png A7200
    

    and

    ExpiresByType image/png A7200
    ExpiresByType image/* A3600
    

    both result in the same thing: The expiry date for PNG files is set to two hours and the expiry date for other image files to one hour, i.e. the more specific ExpiresByType directive wins, regardless of order.

    The changelogs indicate that this behaviour should be consistent from ancient Apache versions through to the latest release.