# Correct regexp for Apache Expires headers

**URL:** <https://www.ruby-forum.com/t/correct-regexp-for-apache-expires-headers/171960>\
**Category:** Rails\
**Created:** [July 12, 2009, 11:40am UTC](https://www.ruby-forum.com/t/correct-regexp-for-apache-expires-headers/171960 "2009-07-12T11:40:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [July 12, 2009, 11:40am UTC](https://www.ruby-forum.com/t/correct-regexp-for-apache-expires-headers/171960/1 "2009-07-12T11:40:02Z")

</div>

Hi

I am trying to get my Apache/Passenger installation to cache all  
assets with a Rails style timestamp. My vhost file contains:

\<VirtualHost \*:80\>  
ServerName www.blabla.se  
DocumentRoot /home/deployer/public/blabla/public

```
    <Directory /home/deployer/public/blabla/public>
            <IfModule mod_expires.c>
                    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|

```

js|css|swf)?[0-9]+$"\>  
ExpiresActive on  
ExpiresDefault “access plus 10 years”

If I use the “catch all” regexp “.(ico|pdf|flv|jpg|jpeg|png|gif|js|  
css|swf)$” then the assets get expires headers, but not if I include  
the demand for a ? and 1 or more digits. I have checked the Perl  
regexp documentation and I cannot see what is wrong with it. It also  
runs well in Ruby, though I am not 100% of the compatibility between  
Ruby and Perl regexp.

Does anyone have a working regexp for this?

Regards

Erik L.

---

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [August 13, 2009, 2:05pm UTC](https://www.ruby-forum.com/t/correct-regexp-for-apache-expires-headers/171960/2 "2009-08-13T14:05:23Z")

</div>

I got the same problem.

---

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [August 14, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/correct-regexp-for-apache-expires-headers/171960/3 "2009-08-14T23:38:46Z")

</div>

Just read an article on this here:  
[http://www.dcmanges.com/blog/asset-versioning-in-rails#comment-14440675](http://www.dcmanges.com/blog/asset-versioning-in-rails#comment-14440675)  
In short, Apache doesn’t seem to support file matching with the query  
string.

Best

Jeff Tucker
