Ask HN: Caching pages with login form/"Hi, Bob" components

https://news.ycombinator.com/item?id=4464833
by SoftwareMaven • 14 years ago
1 2 14 years ago

It has become pretty standard practice to have a login form on every page and, once logged in, to have a "Hi, Bob" type of link to their profile. Naively, this destroys caching.

So what are some ways to deal with this. Ideas I've thought of (with varying degrees of difficulty):

1. Componentize and cache everything on the page in chucnks. Then the final page is a conglomerate of cached chunks. The higher the componententization, the higher the mental complexity but also the higher the potential for re-use.

2. Special case that authentication portion, so the remainder of the page can be cached, but that auth info/form is substituted right before display (that is kind of an ugly, degenerate version of #1). This is pretty easy, but an ugly hack.

3. Use an iframe for the authentication information. Now the page can be cached completely with a simple iframe being regenerated on every request.

4. Use a cookie to store the authentication information and use Javascript to populate it after the page renders. There are obvious problems if a user doesn't use JavaScript.

Are there any other options I'm missing?

Related Stories

Loading related stories...

Source preview

news.ycombinator.com