使用IIS7输出缓存 - 如何使用动态aspx页面?

时间:2010-03-27 19:38:42

标签: asp.net iis-7 caching

我有一个RetrieveBlob.aspx,它获取一些查询字符串变量并返回一个资产。 Eeach url对应一个独特的资产。

在RetrieveBlob.aspx中设置了缓存配置文件。在Web.Config中,配置文件看起来像(在system.web标记下):

<caching>
  <outputCache enableOutputCache="true" />
  <outputCacheSettings>
    <outputCacheProfiles>
      <add duration="14800" enabled="true" varyByParam="*" 
           name="AssetCacheProfile" />
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

好的,这很好用。当我在RetrieveBlob.aspx后面的代码中放置一个断点时,它会在第一次触发,而所有其他时间都不会触发。

现在,我丢弃了缓存配置文件,而不是我在System.WebServer下的Web.Config中使用它:

<caching>
  <profiles>
    <add extension=".swf" policy="CacheForTimePeriod"
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".flv" policy="CacheForTimePeriod" 
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".gif" policy="CacheForTimePeriod" 
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".png" policy="CacheForTimePeriod"    
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".mp3" policy="CacheForTimePeriod" 
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".jpeg" policy="CacheForTimePeriod" 
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
    <add extension=".jpg" policy="CacheForTimePeriod" 
         kernelCachePolicy="CacheForTimePeriod" duration="00:08:00" />
  </profiles>
</caching>

现在缓存不再起作用了。我究竟做错了什么?是否可以在System.WebServer的Caching标签下配置Dynamic aspx页面的缓存配置文件?

我已经尝试添加这样的内容:

<add extension="RetrieveBlob.aspx" policy="CacheForTimePeriod" 
     kernelCachePolicy="CacheForTimePeriod" duration="00:00:30" 
     varyByQueryString="assetId, assetFileId" />

但它不起作用。

网址示例如下:

的http:// {服务器} / {应用} /trunk/RetrieveBlob.aspx?assetId=31809&assetFileId=11829

1 个答案:

答案 0 :(得分:1)

转到:

IIS7 -> Add Cache Rule -> Advanced -> Check Query String Variables 

然后在文本框"assetId,assetFileId"