Forum: Ruby on Rails reverse proxy caching and user specific information

B4d7d1d75ca0c68c42e41c6ee7525c8e?d=identicon&s=25 badnaam (Guest)
on 2010-10-19 19:06
(Received via mailing list)
i am trying to cache a few pages with reverse proxy (using etags) and
though the content across these pages remain the same for all users,
there are some areas (like a div showing the user's image username,
profile link in navbar) that are user specific.

What's the best way to be able to cache these kind of pages using
reverse proxies but not still be able to differentiate the user
specific portions? What do the facebooks of the world do?

A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2010-10-19 19:31
(Received via mailing list)
I think they use JavaScript to inject the current user content into an
otherwise static page. Cache the bulk of the page, including all the
JavaScript, then use a very targeted XHR to replace one or two small
elements. It's still multiple requests, but the size differential
between cached and un-cached content is very large. Plus the outer
page loads immediately, then updates to include the custom stuff.

Set the session to carry the user's id, then ask the session who
requested this XHR before returning the custom results and using
static JavaScript to update that area. If I recall correctly, there is
a Railscast about this very solution.

Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.