To sum up issue #81835, my previous patch that split up drupal.css resulted in a number of smaller CSS files, which dramatically increases the HTTP requests per *INITIAL* page load--slowly down the user experience up to 70%.
On recent work on a VERY MAJOR website, we confirmed that each HTTP request can be vital--these separate files are killing us from both sides of the story.
This patch resolves this issue.
How does it work?
Well at *INITIAL* page load, if the files directory exists and is writeable (e.g., the user has gone to the admin/settings/files page), it will create a single, aggregate CSS, and write this to files/css/md5_name.css This file is then loaded once for each request, reducing HTTP requests by 95%+ for HTTP requests. Since the file is only dynamically created *once*, and not on the fly, the file is cached by user's browsers as well.
Additionally, because we're doing this, we can introduce some basic compression, removing whitespace in the CSS. I've also introduced a new hook, hook_compress_css(), for modules or sites that wish to integrate various CSS compression libraries to really compress things.
Additionally, I've set a new variable, "cache_css" that any site $conf or devel module or other module could make use of as option to turn off CSS caching and it will fallback to the old system.
And of course, if the user can't create a files directory or has write permissions, it falls back to the old system.
And there is a drupal_css_cache_flush() to flush this cache, which is done automatically anytime you visit the themes page. Devel module could make use of this as well :-)
That should cover all bases.
But now what needs to be done--thorough testing, does it work for all themes? I've tested it very thoroughly and so far, so good.
Can it be optimized even more? Maybe, let's see.