Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are correct in your assumptions.</p> <p>Your OutputCache directive is telling the output caching mechanism to cache the entire <em>rendered</em> page for a specific URL, for 600 seconds.</p> <p>In your simple example, you're probably not using any query strings, however, the VaryByParam declaration within the directive allows you to specify a query string parameter that ensures each different value of that parameter is cached separately. For example, if you had:</p> <pre><code>&lt;%@ OutputCache Duration="600" VaryByParam="ProductID"%&gt; </code></pre> <p>then these three different URL's would each be cached individually, and changing the value of the "ProductID" parameter to something not yet cached would ensure that the page is processed and rendered by the ASP.NET runtime correctly:</p> <pre><code>http://www.example.com/viewproduct.aspx?ProductID=123 http://www.example.com/viewproduct.aspx?ProductID=3 http://www.example.com/viewproduct.aspx?ProductID=67 </code></pre> <p>In your example, on your button click, the page has already been previously rendered (and cached) and when you post back again there is no difference in the URL that you are posting back to and effectively reloading, therefore, the ASP.NET runtime will display the cached page to you without going through the process of re-rendering it.</p> <p>Other than by changing the value of a "VaryByParam" parameter, the OutputCache directive is quite a bit of an "all-or-nothing" approach to page caching. There is a "VaryByContol" attribute to the directive, however, that can only be used in ASP.NET user controls, rather an a complete ASP.NET web page.</p> <p>From your question, it sounds more like you need to investigate <em>partial</em> page caching. Either that or a mechanism to invalidate the cache when some event occurs. This is usually done by adding a "cache dependency". </p> <p>For that, the following links should help:</p> <p><a href="http://msdn.microsoft.com/en-us/library/h30h475z%28VS.71%29.aspx" rel="nofollow noreferrer">Caching Portions of an ASP.NET Page</a><br> <a href="http://weblogs.asp.net/scottgu/archive/2006/11/28/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature.aspx" rel="nofollow noreferrer">Tip/Trick: Implement "Donut Caching" with the ASP.NET 2.0 Output Cache Substitution Feature</a><br> <a href="http://scottonwriting.net/sowblog/posts/3513.aspx" rel="nofollow noreferrer">Programmatically Removing a Page from the OutputCache</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload