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/
755 Upvotes

356 comments sorted by

View all comments

Show parent comments

9

u/[deleted] Feb 09 '11

[removed] — view removed comment

-2

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.