Skip to content

Commit

Permalink
Zip ajax response before sending back to the client. Using `applicati…
Browse files Browse the repository at this point in the history
…on/json` content type in order to avoid double zipping by the server
  • Loading branch information
kobizz committed Jun 5, 2019
1 parent 3e60b4a commit bbe1585
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/common/modules/ajax/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,17 @@ private function send_success() {
],
];

echo wp_json_encode( $response );
$json = wp_json_encode( $response );

if ( function_exists( 'gzencode' ) ) {
header( 'Content-Type: application/json; charset=utf-8' );

header( 'Content-Encoding: gzip' );

echo gzencode( $json );
} else {
echo $json;
}

wp_die( '', '', [ 'response' => null ] );
}
Expand Down

0 comments on commit bbe1585

Please sign in to comment.