2012-06-25 33 views
1

我试图使用从HTML 5 Boilerplate project重写规则进行规避浏览器缓存(也称为缓存无效):为什么web.config中声明的缓存清除规则被忽略?

<rewrite> 
    <rules> 
     <rule name="Cachebusting"> 
      <match url="^(.+)\.\d+(\.(js|css|png|jpg|gif)$)" /> 
      <action type="Rewrite" url="{R:1}{R:2}" /> 
     </rule> 
     <rule name="Remove WWW" stopProcessing="true"> 
      <match url="^(.*)$" /> 
      <conditions> 
       <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" /> 
      </conditions> 
      <action type="Redirect" url="http://chewsy.com{PATH_INFO}" redirectType="Permanent" /> 
     </rule> 
    </rules> 
</rewrite> 

如果我尝试用/css/all.123456.css访问我的CSS,它未能找到与该文件错误报告,它正在寻找/css/all.123456.css(不重写)。我试着对"Remove WWW"规则做出评论,看看这是否是冲突,但是是相同的行为。

任何想法为什么这个规则没有被应用和重写的URL?

更新:我在VS2010使用我的Web服务器这些设置: enter image description here

回答

3
<match url="^(.+)\.\d+\.(js|css|png|jpg|gif)$" /> 
<action type="Rewrite" url="{R:1}.{R:2}" /> 

我pressume你想获得/css/all.css,如果没有,张贴想要的结果...

编辑: VS内部开发服务器(卡西尼)不支持IIS URL重写模块,您将不得不使用IIS(Express)或第三方组件(http://urlrewriter.net/)...

+0

这并没有改变任何东西。相同的结果,这意味着'/ css/all.123456.css'没有解析为'/ css/all.css'。 – TMC

+0

@TMC - 什么是解决**到**? –

+0

我得到了404.它看起来没有被重写。 – TMC