Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Web form caching based on GET and POST requests - Part 123

Suggested Videos
Part 120 - Caching multiple responses for a single webform
Part 121 - Controlling caching in code
Part 122 - Fragment caching

In this video, we will discuss about, how webforms are cached based on GET and POST requests. One of my youtube subscribers asked this question, related to Part 120 - Caching mulitple responses for a single web form. Please watch Part 120, from the asp.net video tutorial before proceeding with this video.



We will be using the same example from Part 120 of the asp.net video tutorial, to understand web form caching based on GET and POST requests.

Question asked by the youtube subscriber
When we have set VaryByParam="None", and accessed WebForm1.aspx, the form displayed "All" products as expected. In "Select Product" dropdownlist "All" is selected. Now when I change the selection in the dropdownlist to "iPhone", WebForm1.aspx gets posted back to the server, the form is re-processed. At this point only "iPhone" product is displayed in the gridivew control, and in the dropdownlist "iPhone" is selected.



First Question: Why was the GET request for the webform not cached for "All" products selection in the dropdownlist?
Answer: Actually, the GET request for "All" products selection in the dropdownlist is cached. To retrieve the cached response of the GET request, click any where in the URL address bar in the browser, and press ENTER key. This sends another GET request to the server, which should to return the cached response of the GET request.

Second Question: Why am I not getting the cached response of the GET request when I change the selection in the dropdownlist to "All"? 
Answer: This is because, when the selection in the dropdownlist is changed to "All", a POSTBACK request is sent to the server. Since, for the POSTBACK request there is already a cached version of the webform, we get that version.

I think, when we set VaryByParam="None", a separate response is cached for GET and POST requests.

I welcome any suggestions to improve this answer. Please leave your valuable comments.


1 comment:

  1. SIR, ALL OF YOUR TUTORIAL VIDEOS ARE GREAT,GIVING VERY CLEAN DESCRIPTION.CAN YOU PROVIDE SOME EXAMPLES TO US FOR THESE TUTORIALS?.THAT WOULD BE GREAT.I'VE ONE MORE THING TO SAY.CAN YOU INCLUDE THE TUTORIALS FOR USING JQUERY & JAVASCRIPT IN ASP.NET?

    ReplyDelete

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.