Apache FilesMatch regexp: Can it match by the cache buster 10 digit (rails generated) following the filename?

Posted by ynkr on Pro Webmasters See other posts from Pro Webmasters or by ynkr
Published on 2011-06-30T07:23:19Z Indexed on 2011/07/01 0:31 UTC
Read the original article Hit count: 193

Filed under:
|

According to the apache FilesMatch docs:

The FilesMatch directive provides for access control by filename

Basically, I only want to set an expires header for resources that have a 10 digit "cache buster" id appended to the name. So, here is my attempt at such a thing in my httpd.conf

<FilesMatch "(jpg|jpeg|png|gif|js|css)\?\d{10}$">
    ExpiresActive On
    ExpiresDefault "now plus 5 minutes"
</FilesMatch>

And here is an example of a resource I want to match:

http://localhost:3000/images/of/elvis/eating-a-bacon-sandwich.png?1306277384

Now obviously my FilesMatch regexp is not matching so I am guessing 1 of 2 things is happening. Either my regexp is wonky or the '?1231231231' cache busting part of the file is not part of what apache considers part of the filename. Can anybody confirm and/or give me a way to cache only those resources that will not persist beyond the next deploy?

© Pro Webmasters or respective owner

Related posts about apache2

Related posts about httpd.conf