Output Caching with IIS7 - How To for an dynamic aspx page?

Posted by Lieven Cardoen on Stack Overflow See other posts from Stack Overflow or by Lieven Cardoen
Published on 2010-03-27T19:38:41Z Indexed on 2010/03/27 19:43 UTC
Read the original article Hit count: 446

Filed under:
|
|

I have a RetrieveBlob.aspx that gets some query string variables and returns an asset. Eeach url corresponds to a unique asset.

In the RetrieveBlob.aspx a Cache Profile is set. In Web.Config the profile looks like (under system.web tag:

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

Ok, this works fine. When I put a breakpoint in the code behind of RetrieveBlob.aspx, it gets triggered the first time, and all the other times not.

Now, I throw away the Cache Profile and instead I'm having this in my Web.Config under System.WebServer:

<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>

Now the caching doesn't work anymore. What am I doing wrong? Is it possible to configure under Caching tag of System.WebServer a Caching Profile for a Dynamic aspx page?

I already tried adding something like this:

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

But it doesn't work.

An example of an url is:

http://{server}/{application}/trunk/RetrieveBlob.aspx?assetId=31809&assetFileId=11829

© Stack Overflow or respective owner

Output Caching with IIS7 - How To for an dynamic aspx page?

Posted by Lieven Cardoen on Server Fault See other posts from Server Fault or by Lieven Cardoen
Published on 2010-03-27T18:12:28Z Indexed on 2010/03/27 18:23 UTC
Read the original article Hit count: 446

Filed under:
|
|

I have a RetrieveBlob.aspx that gets some query string variables and returns an asset. Eeach url corresponds to a unique asset.

In the RetrieveBlob.aspx a Cache Profile is set. In Web.Config the profile looks like (under system.web tag:

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

Ok, this works fine. When I put a breakpoint in the code behind of RetrieveBlob.aspx, it gets triggered the first time, and all the other times not.

Now, I throw away the Cache Profile and instead I'm having this in my Web.Config under System.WebServer:

<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>

Now the caching doesn't work anymore. What am I doing wrong? Is it possible to configure under Caching tag of System.WebServer a Caching Profile for a Dynamic aspx page?

© Server Fault or respective owner

Related posts about iis7

Related posts about cache