ata comments on Spring 2010 Meta Thread - Less Wrong

3 Post author: FAWS 11 March 2010 10:27AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (141)

You are viewing a single comment's thread.

Comment author: ata 20 March 2010 10:52:53PM 1 point [-]

Why is it that the Recent Comments and Recent Posts sidebars are populated through AJAX instead of being generated on the server side, considering that they're not dynamically updated or anything?

(I was thinking of submitting a patch that would have the server send them pre-populated, but recalling this quote, I figured I ought to first see if I can find out the perfectly good reason why it was done this way.)

Comment author: saturn 21 March 2010 02:57:09AM 0 points [-]

Since the sidebars are the same on every page, the browser can cache them separately and download them only when they are updated. Before April 2009 they were static HTML.

Comment author: ata 21 March 2010 05:55:41PM *  1 point [-]

Were there tests done to find out if this actually results in a speed increase? As they can't be more than a few kilobytes altogether (probably well within the size of a typical TCP packet), I wouldn't be surprised if doing four XMLHTTPRequests and manipulating the DOM actually slowed it down, even if the results were cached.

I'm using Chrome, and the WebKit web inspector is telling me that each page view is spending 200-300 milliseconds in XHR. Not sure if that means it's not caching them correctly or if that really is how long the JavaScript execution takes.

Comment author: saturn 22 March 2010 03:38:39AM 2 points [-]

You're right about it not being faster. I had assumed it helped with server load, but the commit message mentions something about Google indexing.

Comment author: ata 22 March 2010 07:13:05AM 3 points [-]

It seems like a better way to do this would be to check the User-Agent and only send the sidebar if the agent isn't Googlebot. Or, if we want this to apply to other search engines, then we could still do it with JavaScript, but just include the content encoded in a <script> in the page's <head>, so it wouldn't need to go through the XMLHTTPRequest.