News for hackers. Stuff that matters.
Re:Should All Web Traffic Be Encrypted? by TomGullen on Thursday February 23, 2012 @09:51PM (#3627790)
Lesser known HTTP feature that I love, instead of linking to resources like follows:

<link rel="shortcut icon" href="http://static4.scirra.net/images/favicon.ico />

You should link as follows:

<link rel="shortcut icon" href="//static4.scirra.net/images/favicon.ico" />

The double forward slash will select the current protocol the page is being viewed on which means no security errors if you're switching between http/https!

Re:Should All Web Traffic Be Encrypted? by nzmsv on Thursday February 23, 2012 @11:26PM (#3628031)
Nitpicking here, but this would be a URI rather than HTTP feature. It is described in RFC2396 and is just part of how relative URIs work.
Re:Should All Web Traffic Be Encrypted? by ohashi on Thursday February 23, 2012 @10:07PM (#3627821)
That is a neat trick, does it work on all browsers?
Re:Should All Web Traffic Be Encrypted? by tghw on Friday February 24, 2012 @01:24AM (#3628236)
It does, although IE 7 (and possibly 6) have a bug where they will double request the resource. But, honestly, if they're on IE6 or IE7, the web isn't fast for them anyways.
Re:Should All Web Traffic Be Encrypted? by speleding on Saturday February 25, 2012 @05:05PM (#3633969)
The double request on IE only happens on stylesheets, all other requests (including javascript) are fine.
Re:Should All Web Traffic Be Encrypted? by subleq on Thursday February 23, 2012 @10:09PM (#3627830)
Yep, I've tested it down to IE6.
Re:Should All Web Traffic Be Encrypted? by dm_mongodb on Thursday February 23, 2012 @10:08PM (#3627826)
i think so yes
Re:Should All Web Traffic Be Encrypted? by gurkendoktor on Friday February 24, 2012 @01:39AM (#3628264)
I always expected this to do the same:

<link rel="shortcut icon" href="/static4.scirra.net/images/favicon.ico" />

If it doesn't, then what does it do? Default to http?

Re:Should All Web Traffic Be Encrypted? by eurleif on Friday February 24, 2012 @01:43AM (#3628276)
That's a relative URL. It would be equivalent to http://static4.scirra.net/static4.scirra.net/images/favicon....
Re:Should All Web Traffic Be Encrypted? by gurkendoktor on Friday February 24, 2012 @08:52AM (#3629148)
Wow, this took forever to click. I have never written sites that spanned several servers like that. Thanks!
Re:Should All Web Traffic Be Encrypted? by TomGullen on Friday February 24, 2012 @01:30PM (#3630286)
It's all on one server! We use Scirra.net as a cookieless domain to serve static content from (images, css, js etc) as this speeds requests up because otherwise the cookie data for the page is sent to every resource on the same domain which can slow the page load down somewhat.

1 cookieless domain is probably fine, but I found out that for us 4 subdomains (static1, static2, static3, static4) gives best page load performance. It's been a while now so I've forgotten exactly the reason why more can be good, but I believe the benefit of multiple cookieless domains is to do with parallelisation of requests.

If you set it up right it's pretty easy to do, I just have a function that randomly generates the static URL based on the hash of the name of the resource it's linking to.

For example:

<img src="<%=allocateStaticPath("~/images/logo.png")%>" />

The function then hashes the filename, randomly allocates it to static1,static2,static3 or static4 and then prints the path. Hashing is important, you don't want the resource skipping round static servers otherwise it wont be able to cache, and as hashes are designed to have a random distribution most pages static resources should be pretty evenly spread out across the 4 static sub-domains (I do tweak it on some pages though like the homepage as sometimes it comes out quite unbalanced).

All the staticN.scirra.net subdomains all point to the same folder.

Some people think it's overkill and a waste of time but it's not. Once it's setup right it's very low maintenance. Also, the pages load very fast :) I would offer you to see our homepage http://www.scirra.com but it's in a transitional stage of moving server so a lot of it is quite slow at the moment!

Page load speed is super important especially on the visitors first visit/request. Every second longer it takes the more visitors are going to press back or cancel the request. People are also capable of differentiating between very small periods of time (~10-30ms) so really every ms counts. A fast page load also sets a good precedent that your site is going to be one they will enjoy to browse as no waiting is involved.

Re:Should All Web Traffic Be Encrypted? by gurkendoktor on Saturday February 25, 2012 @09:57AM (#3633042)
Right, I should have said, I have never even worked with sites that span several domains (not servers). But that is a nice trick to know.

Playing around with Construct has been on my To Do list for a long, long time; I'll take note of the serving performance when I do! :)

Re:Should All Web Traffic Be Encrypted? by eCa on Friday February 24, 2012 @11:02AM (#3629563)
It doesn't span several servers. It looks in a directory called static4.scirra.net that is in the webroot of http://static4.scirra.net*.
Re:Should All Web Traffic Be Encrypted? by riffraff on Friday February 24, 2012 @02:52AM (#3628384)
you are probably thinking of a relative link to an image on the same server.