Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] how to Combine external CSS

Viewing 1 replies (of 1 total)
  • Good idea. Sorry about not doing that. Here’s what I had to do.

    1) Since my server does not allow mod_deflate or mod_gzip, I had to compress the jsquery script with PHP. I created a file and placed it in my root directory called gzip.php. Within the file is this code:

    ob_start (“ob_gzhandler”);
    if( isset($_REQUEST[‘file’]) ){
    $file = $_REQUEST[‘file’];
    if( goodfile($file) ){
    $ext = end(explode(“.”, $file));
    case ‘css’:$contenttype = ‘css’;break;
    case ‘js’:$contenttype = ‘javascript’;break;
    header(‘Content-type: text/’.$contenttype.’; charset: UTF-8′);
    header (“cache-control: must-revalidate”);
    $offset = 60 * 60;
    $expire = “expires: ” . gmdate (“D, d M Y H:i:s”, time() + $offset) . ” GMT”;
    header ($expire);
    $data = file_get_contents($file);
    $data = compress($data);
    echo $data;
    function goodfile($file){
    if( file_exists($file) ) return true;
    return false;
    function compress($buffer) {
    $buffer = preg_replace(‘!/\*[^*]*\*+([^/][^*]*\*+)*/!’, ”, $buffer);
    $buffer = str_replace(array(“\r\n”, “\r”, “\n”, “\t”, ‘ ‘, ‘ ‘, ‘ ‘), ”, $buffer);
    return $buffer;
    I then added this to my .htaccess file:

    RewriteEngine on
    RewriteRule ^(.*).js$ pathtoyourwebsite/gzip.php?file=$1.js [L]
    Now all my scripts are compressed. I still have not figured out how to combine the external scripts, but I am pleased with them all being compressed. Saves a lot of space. Hope this is helpful! Moreslides

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WP Super Cache] how to Combine external CSS’ is closed to new replies.