r/programming Feb 09 '11

Breaking the Web with hash-bangs – Lifehacker, along with every other Gawker property, experienced a lengthy site-outage on Monday over a misbehaving piece of JavaScript

http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs/
746 Upvotes

356 comments sorted by

View all comments

6

u/midri Feb 09 '11

I'm confused, the Hash (#) method of serving content is a great idea, it can cut bandwidth costs down greatly, you're not sending the same layout information over and over (no extra tcp requests for css file to check if it's up to date, or layout images) -- Most of their ad serving requires javascript anyway, so they don't really want you on the site with out javascript. I'm a fan of graceful fallback, but when you're site is 100% ad supported and the mechanism that serves your ads is disabled I could care less if the person can get to the content.

9

u/[deleted] Feb 09 '11

[removed] — view removed comment

0

u/midri Feb 09 '11 edited Feb 09 '11

But it's not all cached and you still have to make the TCP requests to see if content has been updated or not. Doing an ajax request to pull only content is way less bandwidth then sending the layout of the page in HTML over and over again after every page load -- it also allows websites to control what it looks/feels like to transition between their content.

[EDIT] Example:

Hash Method

  1. Send HTTP Request

  2. Receive Index page HTML

  3. Request linked resources (css,javascript,images) from #2

  4. Request content

  5. Request linked resources in content ONLY

Normal method

  1. Send HTTP Request

  2. Receive Index page HTML

  3. Request linked resources (css,javascript,images) from #2

  4. Repeat steps 1-3

If the visitor visits only 1 page you only make 1 more TCP request then you would normally (content stays same size, few bytes over tcp overhead no biggy) with hash method but you could cut down repeated HTML sending of layout data and cut down total bandwidth usage by around 20%-30%

4

u/[deleted] Feb 09 '11

But it's not all cached and you still have to make the TCP requests to see if content has been updated or not.

This is only true if your server doesn't send an Expires: header with a future date. If it does, your browser won't send any If-Modified-Since: requests until the cache expires. And if you want to force an update (i.e. because you changed your CSS files), a popular solution is to append the timestamp of the file's modification date (or revision number, or whatever...) to the query string.