Interesting WebResouce.axd cache behavior.

Last post 02-26-2006 7:58 PM by wyx2000. 2 replies.

Sort Posts:

  • Interesting WebResouce.axd cache behavior.

    02-26-2006, 1:30 PM
    • Contributor
      3,349 point Contributor
    • wyx2000
    • Member since 11-25-2002, 6:43 AM
    • Posts 805

    I tried to find out what caused my webpages load so slow. Then I found out the caching of WebResouce.axd. Now my webpages load much fast.

    In the same time, I noticed one interesting thing. WebResouce.axd will cache on client side, and client side(only IE? or all browsers? not quite sure) will even not check for updated resource. That is why WebResouce.axd has a t parameter to tell client get updated resource.

    When I tested. WebResouce.axd did cache on client side. The interesting thing is when I click a visited page, I don't see any WebResouce.axd call. But when I refresh the page. All WebResouce.axd calls happen again. I think this behavoir is a good one, user get cached resources to improve speed, and they can just refresh if they need load the new change. But why we need paramter t then? And what about other browse like firefox? they all work the same way?

     

    thanks

  • Re: Interesting WebResouce.axd cache behavior.

    02-26-2006, 7:13 PM
    Answer
    • Participant
      1,431 point Participant
    • rstrahl
    • Member since 08-20-2003, 1:08 PM
    • Paia, Hawaii
    • Posts 277
    • TrustedFriends-MVPs

    The cache behavior is in part controlled by the web.config Debug setting. When debug mode is off the resource is always reloaded, while when it is on it is always cached. Pressing Refresh on a page forces all cached content to be re-loaded by the browser, so all images, CSS files and linked JavaScript files reload no matter what the cache status is. This is good <g> - otherwise you'd have no way of refreshing those resources if you change them...

    I blogged about this a little while back:

    http://west-wind.com/weblog/posts/4310.aspx

    +++ Rick ---

    Rick Strahl
    West Wind Technologies
    Making waves on the Web
    www.west-wind.com/weblog
  • Re: Interesting WebResouce.axd cache behavior.

    02-26-2006, 7:58 PM
    • Contributor
      3,349 point Contributor
    • wyx2000
    • Member since 11-25-2002, 6:43 AM
    • Posts 805

    Thanks.

    I did some test and found out the debug mode affect the cache. I am not quite sure some of your wording like "while when it is on it is always cached". I thought when debug is off, it will be cached. Anyway, I think that is what you mean. I have two more questions, hope you can give me some idea.

    1, It is nice to use webresource.axd on all my other resources, like js, images. But as you wrote in your article, it is not easy to call a assembly resource. What about just some other file, for example, the js file and image file my usercontrol will reference? I don't think I create assembly for my usercontrol.

    2, I found on every page visit, my static images will be called, like /images/spacer.gif, images is one static folder. From fiddler I can tell the cache-control is set to private, which is right, but I don't see expiry date set as I set on IIS (several days later from now). I guess that is why it calls every images on every page visit. Do you have any idea why the expiry setting on IIS doesn't work?

     

    thanks!

Page 1 of 1 (3 items)