How to detect (with server-side code) whether the ASP.NET page will be cached (on the first request)?

Is it possible to determine if an ASP.NET page will be cached, and if so, how?

The HttpCachePolicy object provides only set-methods. A collection of VaryByParams values ​​is useless if values ​​other than "No" and "*" are set, because they cannot be enumerated, and you can only access them using the key.

Also, I cannot use Reflection.

Any ideas?

+4
source share
1 answer

One approach that might work if you are using ASP.NET 4.0 is to implement your own OutputCacheProvider . Then you can add your discovery logic inside the provider.

See ASP.NET MSDN Caching Overview for an example of adding a provider to your web.config and using the providerName attribute in your @ Page or @Control directive.

+1
source

Source: https://habr.com/ru/post/1307458/


All Articles