Revisiting the “Cookieless Domain” Recommendation
jonathanklein.net
jonathanklein.net
There is no one rule of thumb for performance. Generally, inline everything that's small enough to inline. If it's big enough such that caching a separate file will help you on subsequent page loads, then put it in a separate file.
Test and measure. If you can't measure the difference, it doesn't matter. If you don't measure the difference, the rule you are following probably isn't helping you.
[1] http://www.stevesouders.com/blog/2013/09/05/domain-sharding-...
[2] http://www.stevesouders.com/blog/2008/03/20/roundup-on-paral...
/Yes/.
Unfortunately that day is already today on the Internet, where browsers have unknown design decisions made of unknown reasoning across networks that were optimized for unknown requirements.
We have decades of it, it's so trusted that you're forgetting it even exists. What we don't have are convenient answers for questions at the edge of predictability involving dozens of constantly-moving variables.
I've noticed it regularly on the publish side of the Google Play Store.
The chain reaction this sets off in my head is about 100 FUOC's long. And it goes something like this.
Hey, I just saw a FUOC on the Google Play store admin!
They must not be optimizing CSS delivery for above-the-fold content... [0]
Or maybe they just don't lavish the same resources on admin sites as they do on front-end...
I mean, did anyone else see that? And what if they did? What would they think? They wouldn't think anything, because only a web developer would even recognize a FOUC...
And even if someone else saw it and recognized it for what it was... so what?
If I tried to explain to someone what happened in that moment, that Google, yes, Google had failed to expend all the necessary brain power on ensuring that their markup was not rendered a fraction of a second before their stylesheets were parsed...
And that people actually care about that, actually want to protect users from that horrid sight...
I would be seen for what I am, which is a madman.
[0] https://developers.google.com/speed/docs/insights/OptimizeCS...
This results in seeing the title of the page with a loading spinner and a blank white page. If browsers actually rendered the page (is CSS really that important on a news site?) I would at least be able to see the content.
Please, for the love of God, stop hiding content behind styles. Please. Please please please.
rather than cdns, there should be an sha or md5 hash sent with every asset, like an etag, so that things need not live on a specific domain to be pulled from cache.
EDIT: those downvoting, care to state your case?
The point is that you don't want to stand on only one leg when a flaw in that leg may be discovered in the future.
Admittedly MD5 was a poor example from me in that light...
A more realistic mix might be: sha256+RIPEMD160+Whirlpool.
Or, in crypto-speak: Concatenating outputs from multiple hash functions provides collision resistance as good as the strongest of the algorithms included in the concatenated result. [1]
[1] http://en.wikipedia.org/wiki/Cryptographic_hash_function#Con...
What makes you think you can predict the consequences of an attack against SHA-512?
Don't put all your eggs in one basket.
70 years of cryptographic history.
> Don't put all your eggs in one basket.
Don't use cryptographic primitives in ways they weren't designed for. That's a surefire recipe for disaster.
How does this introduce a new XSS issue? It's no different from the current system. And in this case the hash isn't being used to verify the content, it's there for cache invalidation.
I guess someone could poison your local cache somehow, and maybe that could be a problem with shared cdns. But there are other mechanisms to make sure you're delivered the right content in the first instance.
I think the main issues are actually browser support and having to deal with it in your own framework / code. That's the point people start saying - you know what, the existing system works well enough, I'll jut crank up the expiry on my existing headers and stick a cache buster in the URL when it needs to change.
Your CDN alternative is not clear (to me at least).
As for the cookie concerns: first-time visitors don't have any cookies to be sending. Regular users have a cached copy of your stylesheet. Someone who hasn't been to your site in months probably won't have a cached stylesheet, and if you're worried about the performance impact of cookies for them, then just consider whether that cost is worth paying for whatever benefit you're getting by setting long-lived cookies for users who didn't come back soon after their previous visit.
Site 1 sends <script src="/foo/jquery.js" hash="SHA3:12345...">. Your browser hasn't cached this file, so it downloads jquery.js, verifies the hash and caches the contents. Site 2 sends <script src="/bar/jquery-2.5.js hash="SHA3:12345...">. The browser finds that the hash matches the cached jquery.js and loads that instead of downloading the script again.
The scripts could still be served from CDNs, but it wouldn't have to be the same one to have a cache hit. Popular libraries like jQuery would have so many hits that a CDN might not even be worth the effort. Actually the concept is so simple, it's surprising that this hasn't already been implemented unless there is a security issue that I'm not seeing.
And apparently, even discussing jokes/sarcasm can get you through the shades of grey.
<a href="https://example.com/file.zip"
integrity="ni:///sha256;
skjdsfkafinqfb...ihja_gqg?
ct=application/octet-stream"
download>Download!</a>
That provides integrity checking without encryption. It also helps with caching - rather than expiration times, cache systems can use the hash. If you already have a copy of jquery in cache and it matches the hash, it doesn't matter where it came from.If ES6 (including modules) were supported in browser, it would be pretty awesome as an addition to SPDY... I think we're reasonably 5-6 years off before any broadly available sites can really use it, but it's cool. Similar compared to Web Sockets a few years back.
Given that a lot of interactive data is now pushed to dedicated API services, and images are offloaded for CDN, it's far easier to deliver CSS and JS with the markup on the same deployment(s).
If you're taking that approach, you probably don't care much about performance anyways (I've never seen a pure JS SPA which rendered fast).
Loads & renders in between 0.5-1.0s.
(Though I must say FastMail is rather unique in this regard.)
Seems like we’re going backwards...
If you have a control over backend, you can optimize it further.
I'm using cloudfront and aws, reluctant to let cloudfront be the root CDN because of this. Anyone got any insight?
1. No DNS look up for the second host 2. Many browsers speculatively open a second TCP connection to the original host in anticipation that another request will be made so the TCP negotiation overhead for the second request moves forward 3. CSS is on the critical path for rendering so getting it more quickly improves rendering time
https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefe...
I've done it once for a large front end app, and it worked pretty well - the user gets an almost instant webpage and sees that the stuff is loading.
If I don't see even a loading screen, I assume my connection is bad and reload, instead of giving it a bunch of time to load absolutely everything.
IE's can get to ~80% before a single byte is received.
It's easy to turn off compression on your www domain and turn it on on your cdn domain.
So now you're not compressing your css, which would slow the response time, but by how much I can't say. You could still use css minification.
What I was trying to say is that, if you're security conscious, and running a CDN anyway, it might not be worth the risk to allow (selective) HTTP compression on your main web domain. It would be safer to disable it completely.
Unless you're using SPDY, using a different domain doesn't add any more TLS overhead than using the same domain, right? I didn't think that browsers reuse connections to the same server.
This isn't new to SPDY: HTTP/1.1 has keep-alive.