Encode data in php and uncompress in Javascript (ajax)

Encode data in php and uncompress in Javascript (ajax)

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 :

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

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...

PHP variable to JavaScript In Laravel

In PHP, there is always a limitation on pass PHP variable to the javascript file. Many PHP developers, face this issue. But Laravel has one package which is directly set the variable in js. So, you can use this package for passing a variable from controller to javascript.