Microsoft Content Management Server - Caching only for anonymous user

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > February 2004 > Caching only for anonymous user





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Caching only for anonymous user
Gabriele Cannata

2004-02-24, 4:36 am

Sorry if this is a FAQ,
we have a site that is mainly visited by anonymous users, and we have some
complex pages (they are really CMS templates, by the way).
We are thinking about the possibility of caching only the "guest" version of
a page, while processing the page for each authenticated users. Is it
possible?

Gabriele


Stefan [MSFT]

2004-02-24, 4:36 am

Hi Gabriele,

you could add some logic to the template to check if currently an
authenticated users is logged in and display different content.
Or create a parallel channel and redirect to this when the user is
authenticated.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


"Gabriele Cannata" <g_cannataNOSPAM@hotmail.com> wrote in message
news:eDpbwuv#DHA.2476@TK2MSFTNGP12.phx.gbl...
> Sorry if this is a FAQ,
> we have a site that is mainly visited by anonymous users, and we have some
> complex pages (they are really CMS templates, by the way).
> We are thinking about the possibility of caching only the "guest" version

of
> a page, while processing the page for each authenticated users. Is it
> possible?
>
> Gabriele
>
>



Gabriele Cannata

2004-02-24, 4:36 am

Hi Stefan, actually to execute some logic, you must actually process the
page. What we had in mind was to enable OutputCache on all pages, and then
add a HttpModule to check for some kind of authentication (eg. a cookie) and
in the case the user is authenticate, disable caching forcing asp.net to
process the page, while for anonymous letting the default behaviour of
OutputCacheModule to serve the request from the Cache.
What we weren't able to do was to force the OutputCacheModule to not serve
the request from the cache just for some pages.

I'm thinkingabout implementing a
"OnPreRequestHandlerExecute"/"OnPostRequestHandlerExecute" to avoid caching
of request coming from authenticated user, but it's not clear to me the
right way to go.

For CMS guys:

In CMS, curiously, to disable caching of controls in authoring mode, you can
use "VaryByCustom=CmsControl" which actually
causes GetvaryByCustomString to give a continuosly incrementing integer, so
that for every request you get a new cache entry.
This could be a way to forcing the execution of a page, but the memory waste
would be worse than caching for each user visiting the site.

Any comment?

"Stefan [MSFT]" <stefang@online.microsoft.com> ha scritto nel messaggio
news:%23ta$24v%23DHA.3500@tk2msftngp13.phx.gbl...
> Hi Gabriele,
>
> you could add some logic to the template to check if currently an
> authenticated users is logged in and display different content.
> Or create a parallel channel and redirect to this when the user is
> authenticated.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
>
> "Gabriele Cannata" <g_cannataNOSPAM@hotmail.com> wrote in message
> news:eDpbwuv#DHA.2476@TK2MSFTNGP12.phx.gbl...
some[color=blue]
version[color=blue]
> of
>
>



Stefan [MSFT]

2004-02-24, 5:36 am

Hi Gabriele,

you could do a different approach:
implement a new varyon... and check if the current user is authenticated.
If yes, then create a new random key. this will ensure that a new instance
is served.
For guests always render the same key.

How to implement this is here:
http://weblogs.asp.net/stefan_gossn...2/23/45417.aspx

Please be aware that this will cause lots of copies to be stored in output
cache so it might not scale very well....

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


"Gabriele Cannata" <g_cannataNOSPAM@hotmail.com> wrote in message
news:eft29Ew#DHA.688@tk2msftngp13.phx.gbl...
> Hi Stefan, actually to execute some logic, you must actually process the
> page. What we had in mind was to enable OutputCache on all pages, and then
> add a HttpModule to check for some kind of authentication (eg. a cookie)

and
> in the case the user is authenticate, disable caching forcing asp.net to
> process the page, while for anonymous letting the default behaviour of
> OutputCacheModule to serve the request from the Cache.
> What we weren't able to do was to force the OutputCacheModule to not serve
> the request from the cache just for some pages.
>
> I'm thinkingabout implementing a
> "OnPreRequestHandlerExecute"/"OnPostRequestHandlerExecute" to avoid

caching
> of request coming from authenticated user, but it's not clear to me the
> right way to go.
>
> For CMS guys:
>
> In CMS, curiously, to disable caching of controls in authoring mode, you

can
> use "VaryByCustom=CmsControl" which actually
> causes GetvaryByCustomString to give a continuosly incrementing integer,

so
> that for every request you get a new cache entry.
> This could be a way to forcing the execution of a page, but the memory

waste
> would be worse than caching for each user visiting the site.
>
> Any comment?
>
> "Stefan [MSFT]" <stefang@online.microsoft.com> ha scritto nel messaggio
> news:%23ta$24v%23DHA.3500@tk2msftngp13.phx.gbl...
> rights.
> some
> version
>
>



Gabriele Cannata

2004-02-24, 5:36 am

Thanks Stefan,
that is actually what I meant, and that's why I was looking for a better
solution. Still, I wonder why CMS guys chose that approach for User
Controls, I guess that with many authors online and a long cache duration it
would be a big waste of memory, even worse if the authoring machine is also
a production machine.

"Stefan [MSFT]" <stefang@online.microsoft.com> ha scritto nel messaggio
news:OL9EqPw%23DHA.792@TK2MSFTNGP11.phx.gbl...
> Hi Gabriele,
>
> you could do a different approach:
> implement a new varyon... and check if the current user is authenticated.
> If yes, then create a new random key. this will ensure that a new instance
> is served.
> For guests always render the same key.
>
> How to implement this is here:
> http://weblogs.asp.net/stefan_gossn...2/23/45417.aspx
>
> Please be aware that this will cause lots of copies to be stored in output
> cache so it might not scale very well....
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
>
> "Gabriele Cannata" <g_cannataNOSPAM@hotmail.com> wrote in message
> news:eft29Ew#DHA.688@tk2msftngp13.phx.gbl...
then[color=blue]
> and
serve[color=blue]
> caching
> can
> so
> waste
have[color=blue]
it[color=blue]
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com