Drupal 6 Core Patch for allowing CSS optimization with private files

If you've ever built a large website that requires private files, then you've probably run into this before. In Drupal 6 the CSS optimization requires that the files be stored publicly. This is a known bug that will not be fixed according to the drupal developers.

Normally, this wouldn't be a problem, but IE refuses to allow more than 31 linked stylesheets, and each drupal module adding its own css file, it quickly becomes obvious that you need the CSS to be compressed into a single file. In my attempts, I tried a lot of different fixes including other CSS optimization contributed modules and a custom module of my own, but ultimately each of these solutions leaves something to be desired.

Sadly, the best solution for this issue is to hack (patch) core. Thankfully, someone has already done the hard work.

The following patch provided here by linksunten resolves this issue correctly.
drupal-6.22-572516.patch

To apply this patch, you'll need to follow a few steps.

  1. Create the directory dynamic within your drupal/misc folder, and give it write permission.
  2. Download the patch to the drupal root (wget the link above).
  3. Apply the patch: patch -p1 < drupal-6.22-572516.patch

Voila! Now you're ready to enable the CSS optimization in the Sites Performance area. Good job!