4 ms·
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.i
by TomGullen 15y ago
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 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!
- ohashi 15y agoThat is a neat trick, does it work on all browsers?
- dm_mongodb 15y agoi think so yes
- subleq 15y agoYep, I've tested it down to IE6.
- tghw 15y agoIt 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.
- speleding 15y agoThe double request on IE only happens on stylesheets, all other requests (including javascript) are fine.
- nzmsv 15y agoNitpicking 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.
- gurkendoktor 15y agoI 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?
- eurleif 15y agoThat's a relative URL. It would be equivalent to http://static4.scirra.net/static4.scirra.net/images/favicon.ico http://static4.scirra.net/static4.scirra.net/images/favicon....
- gurkendoktor 15y agoWow, this took forever to click. I have never written sites that spanned several servers like that. Thanks!
- eCa 15y agoIt doesn't span several servers. It looks in a directory called static4.scirra.net that is in the webroot of http://static4.scirra.net* http://static4.scirra.net*.
- TomGullen 15y agoIt'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 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.