Caching strategy, will this work?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Caching strategy, will this work?

BabyPunt
I'd like to have caching in my application. However, it serves up
different content depending on if you are logged in or not.  I'm
thinking, is it possible to offer up a cache for all users not logged
in?  If say the application determines you are logged in, then it
won't use the default cache.  However otherwise it will.

Then, if you log in, it switches you out of the default cache.
Will this work? Good idea or convoluted?
Reply | Threaded
Open this post in threaded view
|

Re: Caching strategy, will this work?

Henrik Nordström
On tor, 2007-09-06 at 14:06 +0800, K J wrote:
> I'd like to have caching in my application. However, it serves up
> different content depending on if you are logged in or not.

Which places a great deal of strain on caching within HTTP... HTTP do
not like to see different content on the same URL..

It is possible to solve this using Vary, but only if you are not using
session cookies on anonymous users. And even then some browsers (mainly
Firefox) will get a bit confused not knowing they have to refresh the
page when the user logs in..

It is however in most cases possible to utilize a little bit of
javascript and style sheets to solve this problem by making the same
page display differently depending on the browser state, moving the
display logics from the server to the browser. A technique used
surprisingly little..

Regards
Henrik

signature.asc (316 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Caching strategy, will this work?

BabyPunt
> Which places a great deal of strain on caching within HTTP... HTTP do
> not like to see different content on the same URL..
>
> It is possible to solve this using Vary, but only if you are not using
> session cookies on anonymous users. And even then some browsers (mainly
> Firefox) will get a bit confused not knowing they have to refresh the
> page when the user logs in..

Could you tell me more about Vary? What is it and how do I use it?

> It is however in most cases possible to utilize a little bit of
> javascript and style sheets to solve this problem by making the same
> page display differently depending on the browser state, moving the
> display logics from the server to the browser. A technique used
> surprisingly little..

So do you think my strategy is feasible?  How would you use javascript
to do this? Could you perhaps give a simple example?
Reply | Threaded
Open this post in threaded view
|

Re: Caching strategy, will this work?

Matus UHLAR - fantomas
> > Which places a great deal of strain on caching within HTTP... HTTP do
> > not like to see different content on the same URL..
> >
> > It is possible to solve this using Vary, but only if you are not using
> > session cookies on anonymous users. And even then some browsers (mainly
> > Firefox) will get a bit confused not knowing they have to refresh the
> > page when the user logs in..

On 07.09.07 02:40, K J wrote:
> Could you tell me more about Vary? What is it and how do I use it?

it's a HTTP header, see RFC 2616, section 14.44, a short example:

   The Vary field value indicates the set of request-header fields that
   fully determines, while the response is fresh, whether a cache is
   permitted to use the response to reply to a subsequent request
   without revalidation. [...]

> > It is however in most cases possible to utilize a little bit of
> > javascript and style sheets to solve this problem by making the same
> > page display differently depending on the browser state, moving the
> > display logics from the server to the browser. A technique used
> > surprisingly little..

> So do you think my strategy is feasible?  How would you use javascript
> to do this? Could you perhaps give a simple example?

a javascript function could check whether it's needed to refrech the page
and call refresh, if it's needed.
--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Despite the cost of living, have you noticed how popular it remains?
Reply | Threaded
Open this post in threaded view
|

Re: Caching strategy, will this work?

Henrik Nordström
On fre, 2007-09-07 at 21:20 +0200, Matus UHLAR - fantomas wrote:

> a javascript function could check whether it's needed to refrech the page
> and call refresh, if it's needed.

Was more thinking of a javascript which checks if there is a cookie
enabling the "logged in" functions of the web site, and updating the
stylesheet enabling those features to be shown.

Regards
Henrik

signature.asc (316 bytes) Download Attachment