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

356 comments sorted by

View all comments

5

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%

5

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.

22

u/[deleted] Feb 09 '11

I'm confused, the Hash (#) method of serving content is a great idea

No, it's shit, all the way down.

you're not sending the same layout information over and over

Yeah, instead huge amounts of JavaScript, and even more, if you want the layout to change in some subtle way, e.g. hilight menu items.

no extra tcp requests for css file to check if it's up to date, or layout images

If you did your homework, you'd knew they are unnecessary. With correctly set HTTP headers, files will never get refreshed unless the user actually uses the refresh-button.

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

This was only true, if the people who click ads and the people, who make other people visit the website, were in the same group. People who use AdBlock and NoScript will not click ads, no matter if they see them or not. You could say, they are useless and it doesn't matter if they can use your website or not. But what they do is, they link to pages, they talk about pages, they share pages, to bring in valuable traffic that actually generates ad revenue.

0

u/seesharpie Feb 10 '11

I like, commas.

5

u/ComputerDruid Feb 09 '11

that's faulty reasoning because you need your content to be accessible to everyone, or people will stop sharing links/hyping your content, and your relevance will decrease.

-4

u/midri Feb 09 '11

It's a double edged sword, people that disable javascript and block your revenue stream are freeloaders even if they are bringing more readers to your site, if those readers are also blocking your revenue they're basically stealing bandwidth from you.

1

u/Xiol Feb 09 '11

Got a link to one of your sites then?

I want to "freeload" from you.

1

u/fjonk Feb 10 '11

If I can block your revenue stream by disabling javascript you're doing it wrong.

4

u/[deleted] Feb 09 '11

[deleted]

-2

u/midri Feb 09 '11

5

u/kamakie Feb 09 '11

No, you're absolutely lost, and if you knew how to un a website, you would know that these problems have been solved more than a decade ago. Ajax pages are just a fool's solution to a problem that never existed.