While I am working on cache, there is something like
VaryByParam
in page directive. So what is this? Can anybody explain it to me?
To quote from the MSDN documentation:
A semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes, or a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each combination of specified parameters. Possible values include none, an asterisk (*), and any valid query string or POST parameter name.
So, if you set it to "A;B"
, then these URLs will be cached separately:
http://example.com/yourpage.aspx?A=1&B=4 http://example.com/yourpage.aspx?A=1&B=3 http://example.com/yourpage.aspx?A=2&B=3
but those URLs will access the same cache entry:
http://example.com/yourpage.aspx?A=1&C=4 http://example.com/yourpage.aspx?A=1&C=3
From @ OutputCache (MSDN):
A semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes, or a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each specified parameter. Possible values include none, *, and any valid query string or POST parameter name.
By using it, if you call your page using same variable value, that page will be retrieved from your cache and will not be executed until time especified in Duration
argument be reached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With