开发者

Apache FilesMatch : How to only match assets with a timestamp appended

I just wrote and answered a question regarding what apache FilesMatch recognizes as the filename; see Here for more on that, but the skinny is that apache does not recognize anything after the file extension, which includes the (rails appended) times开发者_高级运维tamp, on an asset as part of the filename.

That kind of sucks because we have assets that, for one reason or another, are not timestamped for cache-busting purposes, so a blanket match like this:

<FilesMatch "\.(ico|jpe?g|png|gif|js|css)$">
    ExpiresActive On
    ExpiresDefault "now plus 1 year"
</FilesMatch>

Is going to match both assets that are eligible for cache busting as well as those that are not. For those that are not, well, this can be bad.

So, can anybody tell me how to match assets only if they have a \?\d{10} following the filename?


I found a hack that is not ideal, but given the limitations, will work. Check out these two sites for the solution:

  • http://www.stephensykes.com/blog_perm.html?157
  • http://bibwild.wordpress.com/2010/09/22/browser-caching-of-rails-assets-for-real/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜