Last active
July 26, 2019 09:50
-
-
Save thewinterwind/9728730 to your computer and use it in GitHub Desktop.
How to gzip AJAX response with PHP (Laravel 4 flavor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function all() | |
{ | |
if (Request::ajax()) { | |
$encoded_html = gzencode(Model::all(), 9); | |
header('Content-Length: ' . strlen($encoded_html)); | |
header('Content-Encoding: gzip'); | |
return $encoded_html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment