VaryByParam attribute in OutputCache directive - Caching pages and data

Q.  What is the use of VaryByParam attribute in OutputCache directive?
- Published on 27 Jul 15

a. You can neglect VaryByParam attribute while using Page output caching.
b. The VaryByParam attribute determines which versions of the page output are actually cached.
c. The VaryByParam attribute determines which web page is cached in database.
d. None of the above.

ANSWER: The VaryByParam attribute determines which versions of the page output are actually cached.
 

    Discussion

  • df   -Posted on 30 Jul 19
    fddfgdsfsef
  • Nihal   -Posted on 24 Sep 15
    This attribute creates a new instance of a page to be cached when a different parameter is passed to the page. The parameter can be passed by either a query string parameter or a form parameter.
    You can assign two special values to the VaryByParam attribute:
    none: Parameters will be ignored. Only one version of the page is cached.
    *: New cached version of the page will be created, if there is a change in any
    query string.
    Example:
    <%@ OutputCache Duration=”3000” VaryByParam=”id” %>
    Each time a different id as a parameter is passed to the .aspx page, another version of the same page is cached in memory.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)