Log in

No account? Create an account
Friends page in JavaScript - brad's life [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Friends page in JavaScript [Sep. 12th, 2005|10:49 pm]
Brad Fitzpatrick
[Tags|, , ]

In my copious free time, I've "ported" the LiveJournal friend's page algorithm from Perl (running on the server), to JavaScript (running in the browser).

So instead of making one huge friends page request and getting back a rendered document with 95% duplicate stuff that your client has already downloaded 15 seconds ago when you habitually hammered refresh, your client instead makes dozens of tiny requests, easily cachable on both the client and server, all the way up to the BIG-IP where I can later just instruct it to 304 any If-Modified-Since request on certain immutable URLs. (ala /userpic/ requests)

Plus it can have a background thread polling the last updated times of your friends page, deciding when to refresh itself, just doing the minimum work necessary to update fully. And even if you hit shift-reload to cache-bust, that only cache-busts the pages necessary to onLoad() the document. After that, javascript takes over so the browser goes back to caching. (Had to do some an old-school work-around to make Firefox cache, but IE behaves.... I wish XmlHttpRequest's caching behavior was specified and consistent.)

Anyway, works in IE/Safari/Firefox. Been reading my friend's page in it the past couple days. Pretty addictive.

I'll post a URL when it's beautified a bit and it's not lacking 75% of its future feature set.

[User Picture]From: matthew
2005-09-13 06:25 am (UTC)
Rock on. Anything that reduces load makes me a happy admin :)

Why aren't we 304'ing If-Modified-Since requests on those immutable URLs already? It would save some requests from googlebot.
(Reply) (Thread)
From: evan
2005-09-13 06:50 am (UTC)
for the current entry pages on lj, they can change -- you can edit the post, or get another comment, etc. i think brad constructs unique urls each time the page changes so a given url is always static.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2005-09-13 07:06 am (UTC)
There aren't many immutable URLs right now. Just /userpic/* really.
(Reply) (Parent) (Thread)