function compress_css($css) {
    // Remove comments
    $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
    // Remove whitespace
    $css = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $css);
    return $css;
}
Dont’ forget that, if you are using PHP to output CSS, you’ll need to serve the correct headers:
header("Content-type: text/css");
header("Expires: " . gmdate("D, d M Y H:i:s", (time() + 604800000)) . " GMT");