Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

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.


2 comments:

  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
  2. sir i have a question
    how many form we can define in asp.net webform

    if i have a form in my master page and another in my content page which is linked with that master page

    which is possible multipal form in asp.net

    ReplyDelete

It would be great if you can help share these free resources