• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GZip Compression for Website with Ajax

#1
Hi everyone,
i would like to enable gzip-compression for my website.
But than i have a problem with my ajax-requests.
E.g i run into js error (because i get a compressed json).
I guess i cant handle this with jQuery, so is it possible to disable the gzip compression for some controller-functions?

Eg. Controller/func1 = compression on
      Controller/func2 = compression off

Thank you !  Smile

//Im not sure if "Best Practices" or "General Help" is the correct section for this.
Reply

#2
Why not just rely on mod_deflate (an .htaccess solution)?
Reply

#3
What do you mean by "i run into js error (because i get a compressed json)"?
Json should remain valid even if compressed.

Could you provide an example of what a request looks like compressed (invalid) and uncompressed (valid), as well as your javascript code which can't parse the compressed code.
Reply

#4
Try this:

1. Open php.ini
2. Add zlib.output_compression=On
3. Save
4. Reset server (if needed)
Reply

#5
(04-20-2017, 12:04 PM)antony Wrote: What do you mean by "i run into js error (because i get a compressed json)"?
Json should remain valid even if compressed.

Could you provide an example of what a request looks like compressed (invalid) and uncompressed (valid), as well as your javascript code which can't parse the compressed code.
If "compress_output" = false, than i get a valid json back.
If "compress_output" = true, i dont get any data back from the api. (But get 200 OK from Server)

@Diederik Thank you, that work. 

@AzrielOmega Mhh that didnt effect the loading-size of my page...
Reply

#6
Enabling compression should not break AJAX responses. Did you check your error log?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.