views:

86

answers:

1

Is there an easy way to cache ASP.NET whole page for anonymous users only (forms authentication used)?

Context: I'm making a website where pages displayed to anonymous users are mostly completely static, but the same pages displayed for logged-in users are not.

Of course I can do this by hand through code behind, but I thought there might be a better/easier/faster way.

A: 

You could use VaryByCustom, and use a key like username.

Bruno Reis
The problem with this is that it will cache pages displayed to logged-in users too. In my case, those pages are already partially cached, whereas some parts cannot be cached at all (even for the same user).Of course, I can set VaryByCustom key to a random value if user is logged in, but it will have huge performance issues.
MainMa