WordPress.org

Make WordPress Core

Changeset 10372


Ignore:
Timestamp:
01/17/2009 02:08:15 PM (9 years ago)
Author:
azaozz
Message:

Use gzip instead of deflate as more servers seem to understand it, add separate switch for disabling CSS compression

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/load-scripts.php

    r10357 r10372  
    8686}
    8787
     88// Discard any buffers
     89while ( @ob_end_clean() );
     90
    8891if ( isset($_GET['test']) && 1 == $_GET['test'] ) {
    8992    if ( ini_get('zlib.output_compression') )
    9093        exit('');
    91    
    92     $out = 'var wpCompressionTest = 1;';
    9394
    94     $compressed = false;
    95     if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') ) {
    96         header('Content-Encoding: deflate');
    97         $out = gzdeflate( $out, 3 );
    98         $compressed = true;
    99     } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
     95    if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
    10096        header('Content-Encoding: gzip');
    101         $out = gzencode( $out, 3 );
    102         $compressed = true;
     97        $out = gzencode( 'var wpCompressionTest = 1;', 3 );
    10398    }
    10499   
    105     if ( ! $compressed )
     100    if ( ! isset($out) )
    106101        exit('');
    107102   
     
    124119require(ABSPATH . '/wp-includes/version.php');
    125120
    126 // Discard any buffers
    127 while ( @ob_end_clean() );
    128 
    129121$compress = ( isset($_GET['c']) && 1 == $_GET['c'] );
    130122$expires_offset = 31536000;
     
    143135
    144136header('Content-Type: application/x-javascript; charset=UTF-8');
    145 header('Vary: Accept-Encoding'); // Handle proxies
    146137header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
    147138header("Cache-Control: public, max-age=$expires_offset");
    148139   
    149 if ( $compress && ! ini_get('zlib.output_compression') ) {
    150     if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') ) {
    151         header('Content-Encoding: deflate');
    152         $out = gzdeflate( $out, 3 );
    153     } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
     140if ( $compress && ! ini_get('zlib.output_compression') && function_exists('gzencode') ) {
     141    header('Vary: Accept-Encoding'); // Handle proxies
     142    if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) {
    154143        header('Content-Encoding: gzip');
    155144        $out = gzencode( $out, 3 );
  • trunk/wp-admin/load-styles.php

    r10357 r10372  
    124124
    125125header('Content-Type: text/css');
    126 header('Vary: Accept-Encoding'); // Handle proxies
    127126header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
    128127header("Cache-Control: public, max-age=$expires_offset");
    129128   
    130 if ( $compress && ! ini_get('zlib.output_compression') ) {
    131     if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') ) {
    132         header('Content-Encoding: deflate');
    133         $out = gzdeflate( $out, 3 );
    134     } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
     129if ( $compress && ! ini_get('zlib.output_compression') && function_exists('gzencode') ) {
     130    header('Vary: Accept-Encoding'); // Handle proxies
     131    if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) {
    135132        header('Content-Encoding: gzip');
    136133        $out = gzencode( $out, 3 );
  • trunk/wp-includes/js/tinymce/wp-tinymce.php

    r10369 r10372  
    11<?php
     2
     3$basepath = dirname(__FILE__);
    24
    35while ( @ob_end_clean() );
     
    2325if ( isset($_GET['c']) && 1 == $_GET['c'] && ! ini_get('zlib.output_compression') && false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) {
    2426    header('Content-Encoding: gzip');
    25     echo get_file('wp-tinymce.js.gz');
     27    echo get_file($basepath . '/wp-tinymce.js.gz');
    2628} else {
    27     echo get_file('wp-tinymce.js');
     29    echo get_file($basepath . '/wp-tinymce.js');
    2830}
    2931exit;
  • trunk/wp-includes/script-loader.php

    r10368 r10372  
    597597
    598598        $ver = md5("$wp_scripts->concat" . "$wp_scripts->concat_version");
    599         $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&amp;load=" . rtrim($wp_scripts->concat, ',') . "&amp;ver=$ver";
     599        $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . rtrim($wp_scripts->concat, ',') . "&ver=$ver";
    600600        echo "<script type='text/javascript' src='$src'></script>\n";
    601601    }
     
    607607
    608608function wp_print_admin_styles() {
    609     global $wp_styles, $concatenate_scripts, $compress_scripts;
     609    global $wp_styles, $concatenate_scripts, $compress_css;
    610610
    611611    if ( !is_a($wp_styles, 'WP_Styles') )
     
    616616
    617617    $wp_styles->do_concat = $concatenate_scripts;
    618     $zip = $compress_scripts ? 1 : 0;
     618    $zip = $compress_css ? 1 : 0;
    619619
    620620    $wp_styles->do_items(false);
     
    624624            $ver = md5("$wp_styles->concat" . "$wp_styles->concat_version");
    625625            $rtl = 'rtl' === $wp_styles->text_direction ? 1 : 0;
    626             $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&amp;rtl={$rtl}&amp;load=" . rtrim($wp_styles->concat, ',') . "&amp;ver=$ver";
     626            $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&rtl={$rtl}&load=" . rtrim($wp_styles->concat, ',') . "&ver=$ver";
    627627            echo "<link rel='stylesheet' href='$href' type='text/css' media='all' />\n";
    628628        }
     
    638638
    639639function script_concat_settings() {
    640     global $concatenate_scripts, $compress_scripts;
     640    global $concatenate_scripts, $compress_scripts, $compress_css;
    641641
    642642    $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
     
    647647    if ( $compress_scripts && ! get_option('can_compress_scripts') )
    648648        $compress_scripts = false;
     649
     650    $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
     651    if ( $compress_css && ! get_option('can_compress_scripts') )
     652        $compress_css = false;
    649653}
    650654
Note: See TracChangeset for help on using the changeset viewer.