سؤال

In the process of investigating slow view rendering, I was looking at the "views" tab and was trying to figure out which user controls were cached and which ones were not.

Usually the first entry shows something like:

| Path                     | Check Cache | Found  | Details            |
|--------------------------|-------------|--------|--------------------|
|~/Path/To/UserControl.ascx| true        |  false | Not found in cache |
|~/Path/To/UserControl.ascx| false       |  true  | key    | value     |

All user controls appear the same way, regardless of any caching directive such as :

OutputCache Duration="3600" VaryByParam="none" Shared="True"

Is glimpse broken or have I bungled the output cache directive?

هل كانت مفيدة؟

المحلول

The "Check Cache" column in Glimpse has to do with the view engine's cache - not output cache.

For example, given this (less detailed) output:

Ordinal | Requested View | View Engine | Check Cache | Found
--------|----------------|-------------|-------------|------
1       | Index          | WebForms    | true        | false
2       | Index          | Razor       | true        | false
3       | Index          | WebForms    | false       | false
4       | Index          | Razor       | false       | **true**

What MVC is doing and Glimpse is trying to show is:

  1. Ask the first view engine registered (WebForms) to check in its internal cache for a view called Index - but it was unable to find that view (which is why "Found" is false).
  2. MVC does not give up. It then asks the next view engine registered (Razor) to check in its internal cache for a view called Index - but it was also unable to find that view.
  3. MVC continues to be persistent and goes back to the first view engine (WebForms), asking for the view called Index directly, not from cache. In the case of WebForms, this means looking for a *.aspx file on disk - but the view was not found.
  4. Finally MVC asks Razor again to find the view (this time checking *.cshtml files on disk) and the view is found.

There is a bit more information about the view tab on the Glimpse site.

I hope this helps!

NOTE: When ASP.NET is in debug mode, WebForms and Razor never cache their views.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top