views:

91

answers:

1

I would like to cache my website with memcache as much as possible. There are rare modifications (somewhat like in a forum) which I am perfectly ok with re-caching once change is made. My only concern is login information (similar to how stackoverflow has a bar on top). This is how I am doing it right now:

 $('div#user_bar').load('/login-info/');

(jQuery on a fully cached page loads up userinfo)

However, I think I can do without dynamic pages completely. My idea is this:

On login: create cookie `logged_in`:true
On each page: if JS finds cookie is set: show links to logout, settings, etc
              if not: show link to login page
On logoff: delete cookie

No actual userinfo is stored in cookies, not even username.

How secure, reasonable, sane is this? Any ideas? Am I missing something? Thank you.

Disclaimer: This is more of an exercise than a production environment. But I am trying to keep security and performance in mind nonetheless.

A: 

About your main target: Caching dynamic pages is reasonable. If you work on the ASP.NET platform, you might want to have a look at the output cache feature which does exactly this, even including dynamic substitutions. 4 Guys from rolla.com have a nice starter article with links to all the details.

Regarding the non-userspecific pages: I doubt that this can work for anything but the most simple pages. Web applications usually allow different operations for different users, and if it's only the change of your password. You probably have to pass specialized content to the client at some point, and that's where the dynamic substitutions of the ASP.NET output cache come into play.

Malte Clasen