Ask HN: Caching pages with login form/"Hi, Bob" components
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?
2 comments
[ 3.3 ms ] story [ 17.1 ms ] thread1 and 2 work fine if you're doing the caching. Exporting that kind of caching to CDNs may be a bit more tricky (not impossible though...)
Their solution is similar to #4.
To your concern about disabled javascript, you can still do what they describe but add CSS classes to all elements that would need to be hidden for non-admin/logged in users and just use display:none;
Finally, I would given some serious thought to who the audience is for the application. For most applications the % of users for whom javascript is disabled is so tiny for the amount of work it would require that it is not worth the effort.