Thursday, May 13, 2010

Script Resource and HTTP 304

Here are my findings on HTTP 304’s -

Issue – HTTP 304 every time a page(rendered html) has reference to ScriptResource.axd or WebResource.axd. this reference is added by Ajax tool kit.

Context – ScriptManager adds .axd references in the rendered html as below to get the javascript support for AJAX.

User Impact –
The user is neither being redirected to the error page, nor getting any AJAX/functionality errors. But, some server traffic-monitoring softwares like the tea-leaf show them as errors in their statistics.

Probable Cause –
The actual page is being rendered with #pragma set to ‘no-cache’. So, when the page is refreshed, it is trying to load again from server.

When we verify the request/response headers –
The request headers for the page and the .axd files have cache-control set to ‘no-cache’.
While the page response still has ‘no-cache’, the .axd file response (with 304 status) has ‘public’, which means the file can be cached.

Based on the response header’s cache control value, it is trying to verify the .axd file version with cached version and hence, the HTTP 304 – ‘Not Modified’ error. 304 basically says, the resource is not modified from its last cached copy.


Possible Fixes –
Extend the ScriptResourceHandler (that implements IHttpHandler) and Override the ProcessRequest method.

The fix for this should either be – force-get the .axd files as if they are not cached OR use only the cached version of the .axd files.

For the first fix –
Set the Expires property to a past date which would effectively set the cache-control to ‘no-cache’.
Setting cache-control to ‘no-cache’ is also necessary to handle the behaviour on all browsers.

For the second fix – (this may NOT be the recommended one)
Set the status code of the response in the HttpContext to ‘200’ if it is ‘304’.

The first fix can have a slight impact on performance, but consistent.
The second fix is not really consistent(, at least when I verified). Theoritically it should work and it should have no impact on performance.

To replicate the issue, do browser refresh on any that has ScriptManager. Use Fiddler or similar software to view the 304-response.

MY CONCLUSION ON THIS -
From my knowledge and analysis on HTTP 304’s, I’ve found that this is a FEATURE of HTTP rather than a bug. That’s the right message the server is sending in accordance with Http protocol, and it is not an error/warning message, but just a status message.

304 basically says, the resource is not modified from its last cached copy and the browser can load it from its local cache. This way, it avoids the resource being unnecessarily transferred between client and server, thereby, enhancing the performance of the application.

Some iis traffic-monitoring softeware, like the Tea leaf can misread it as an error, while it is actually a feature. They will have to be configured accordingly.

32 comments:

  1. Does your blog have a contact page? I'm having problems
    locating it but, I'd like to send you an email. I've got some ideas for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it develop over time.



    Stop by my site :: personalized wine glasses no minimum

    ReplyDelete
  2. Hey just wanted to give you a brief heads up and let you know a few
    of the pictures aren't loading correctly. I'm not sure why but
    I think its a linking issue. I've tried it in two different browsers and both show the same outcome.


    Feel free to visit my site: personalized wine glasses cheap no minimum

    ReplyDelete
    Replies
    1. Thanks for letting me know. Will try to find out and fix if there are any such issues.

      Delete
  3. Hi there, I wish for to subscribe for this
    weblog to obtain hottest updates, thus where can i do it please
    help.

    Here is my site; medical insurance billing and coding job description

    ReplyDelete
    Replies
    1. Thanks. There is a SUBSCRIBE TO section in the right hand pane in this blog if you scroll up. Under it, you find two boxes - Posts and Comments. If you click on Posts, you will be notified about any new posts. HTH, Please let me know if you still find any issues.

      Delete
    2. BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  4. Hey there! This post could not be written any better! Reading through this post reminds me of my previous room mate!
    He always kept chatting about this. I will forward this article to him.
    Fairly certain he will have a good read. Thanks for sharing!


    Stop by my weblog; medical coding jobs from home

    ReplyDelete
    Replies
    1. Thanks, Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  5. Hello, I think your site might be having browser compatibility issues.
    When I look at your blog site in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping.

    I just wanted to give you a quick heads up! Other then that, fantastic blog!


    Here is my web site medical coding jobs from home

    ReplyDelete
    Replies
    1. Thanks for the feedback. Will check any UI issues and fix if found.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  6. My brother suggested I might like this blog. He was totally right.
    This post actually made my day. You cann't imagine simply how much time I had spent for this information! Thanks!


    Feel free to visit my web-site: personalized wine glasses cheap no minimum

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  7. Ԝow, that's what Ι was searching for, աhat a material!

    existing hеre att this web site, thanks adsmin of this web site.


    Loook at my web site Twin Cities Area Luxury Real Estate

    ReplyDelete
    Replies
    1. Thanks.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  8. I relish, cause I discovered exactly what I was
    having a look for. You have ended my four day lengthy hunt!

    God Bless you man. Have a nice day. Bye

    Feel free to surf to my website: work from
    home jobs in hyderabad [iesrutadelaplata.juntaextremadura.net]

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  9. Link exchange is nothing else but itt is only placing the other person's weblog link on your page at appropriate place
    and other person will also do similar in favor of you.


    Also visit my weblog - vancouver furnace repair

    ReplyDelete
  10. Fabulous, what a weblog it is! Thhis website provides helpful data to us, keep
    it up.

    Heree is my webpage - clash of clans triche

    ReplyDelete
    Replies
    1. Thanks.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  11. Hi there, I enjoy reading all of your post. I wanted to
    write a little comment to support you.

    Also visit my webb page: Spanish grammar checker free

    ReplyDelete
    Replies
    1. Thanks.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  12. Hey! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a
    outstanding job!

    My webpage :: best wordpress ecommerce themes

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stiff.

      Delete
  13. Hello! This is my first comment here so I just wanted to gice a quick
    shout out and say I genuinely enjoy reading through your posts.
    Can you recommend any other blogs/websites/forums thzt go over thee same topics?

    Thank you!

    Alsso visit my web-site ... al jazeera english

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stuff.

      Delete
  14. Thanks for a marvelous posting! I seriously
    enjoyed reading it, you wwill be a great author. I will make certain tto bookmark your blog and may come back
    later in life. I want to encourage you to continue youir
    great work, have a nic weekend!

    Also visit my weblog; spanish jokes tumblr

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stuff.

      Delete
  15. Hi there Dear, arre you genuinely visiting this website on a regular basis,
    if so afterward you wioll definitely obtain good know-how.


    myweb site: past subjunctive wearing clothes in Spanish quizlet

    ReplyDelete
    Replies
    1. Thanks for the feedback.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stuff.

      Delete
  16. Great website. Plenty of useful information here. I aam sending it to several frends ans additionally shwring in delicious.

    And naturally, thanks for your sweat!

    Also visit my page :: tips to learn Spanish quickly

    ReplyDelete
    Replies
    1. Thanks. Glad to know that.
      BTW, I've been posting all my technical stuff in my tech-specific blog - techietr.blogspot.in. Do visit that blog for more technical stuff.

      Delete