Types of parameter supported by OutputCache - Caching pages and data

Q.  How many types of parameter supported by OutputCache?
- Published on 27 Jul 15

a. VaryByParam
b. VaryByControl
c. VaryByHeader
d. VaryByCustom
e. All of the above

ANSWER: All of the above
 

    Discussion

  • Raj   -Posted on 23 Sep 15
    You enable Page Output Caching by adding an <%@ OutputCache %> directive to a page. It supports the following parameter.

    VaryByCustom: It enables you to gets a list of custom strings that the output cache will use to vary the user control. If you provide "browser" for this property, then the user control will be varied by provided browser type and major version number.
    VaryByHeader: It enables you to create different cached versions of a web page when the value of a particular browser header changes. A semicolon-separated list of HTTP headers used to vary the output cache.
    VaryByParam: 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.
    VaryByControl: It is used to create different cached versions of a page depending on the value of a specific control in the page.

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.)