In order to reduce the size of my json file, I wanted to zip it. Hence, I am trying to compress json data file sent from php server :
header('Content-Encoding: gzip');
$output = gzencode(json_encode($data));
echo $output;
And then, uncompress it in javascript (ajax methodd) :
$.ajax({
url: url,
type: "GET",
headers : {'Accept-Encoding': 'gzip '},
async: true,
success: function (data) {
console.log("sucess !!");
console.log(data);
...
)};
I also modified apache server in order to uncompress it automagically :
LoadModule deflate_module modules/mod_deflate.so
And :
<IfModule mod_headers.c>
<FilesMatch ".(js|css|xml|gz|txt|json)$">
Header append Vary: Accept-Encoding
</FilesMatch>
However, I couldnt get the data properly (it stills compress).
Could you please let me know what I am doing wrong ?
Thank you