阿帕奇FilesMatch:如何只附加一个时间戳相匹配的资产 [英] Apache FilesMatch : How to only match assets with a timestamp appended

查看:216
本文介绍了阿帕奇FilesMatch:如何只附加一个时间戳相匹配的资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只写和回答了有关什么阿帕奇FilesMatch识别为文件名的问题;看<一个href=\"http://stackoverflow.com/questions/6531300/apache-filesmatch-regexp-can-it-match-by-the-cahce-buster-10-digit-rails-genera\">Here更多关于这一点,但骨感的是Apache不将文件扩展名,其中包括(轨道追加)时间戳后承认什么,在一个资产作为文件名的一部分。

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) timestamp, 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.

那么,有谁能够告诉我如何搭配资产,只有当他们有一个\\?\\ d {10}文件名以下?

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/

这篇关于阿帕奇FilesMatch:如何只附加一个时间戳相匹配的资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆