Make WordPress Core

Changeset 43618


Ignore:
Timestamp:
09/03/2018 09:16:27 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Script loader: remove (PHP based) compression from load-styles.php and load-scripts.php. WIth the amount of scripts and stylesheets grown a lot over the years, it has become pretty slow and consumes a lot of server resources. Also, most servers are set to compress PHP output anyway.

Props LucasRolff, azaozz.
Merges [43580] to the 4.9 branch.
Fixes #44815. See #43308.

Location:
branches/4.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/load-scripts.php

    r38470 r43618  
    2929require( ABSPATH . WPINC . '/version.php' );
    3030
    31 $compress = ( isset($_GET['c']) && $_GET['c'] );
    32 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
    3331$expires_offset = 31536000; // 1 year
    3432$out = '';
     
    5957header("Cache-Control: public, max-age=$expires_offset");
    6058
    61 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
    62     header('Vary: Accept-Encoding'); // Handle proxies
    63     if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    64         header('Content-Encoding: deflate');
    65         $out = gzdeflate( $out, 3 );
    66     } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
    67         header('Content-Encoding: gzip');
    68         $out = gzencode( $out, 3 );
    69     }
    70 }
    71 
    7259echo $out;
    7360exit;
  • branches/4.9/src/wp-admin/load-styles.php

    r38470 r43618  
    2929    exit;
    3030
    31 $compress = ( isset($_GET['c']) && $_GET['c'] );
    32 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
    3331$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
    3432$expires_offset = 31536000; // 1 year
     
    8179header("Cache-Control: public, max-age=$expires_offset");
    8280
    83 if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
    84     header('Vary: Accept-Encoding'); // Handle proxies
    85     if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    86         header('Content-Encoding: deflate');
    87         $out = gzdeflate( $out, 3 );
    88     } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
    89         header('Content-Encoding: gzip');
    90         $out = gzencode( $out, 3 );
    91     }
    92 }
    93 
    9481echo $out;
    9582exit;
Note: See TracChangeset for help on using the changeset viewer.