Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return gziped API response in Laravel?

Tags:

gzip

laravel

I generally using such response syntax:

return response()
    ->json(['request'=> $data, 
        'response' => $response, 
        'client' => $client], 200);

How could I make it gziped?

like image 821
vppy Avatar asked Feb 01 '19 13:02

vppy


1 Answers

It's supposed to be configured per webserver basis. So it depends on which webserver you are using.

If it's Apache that you're using, mod_deflate is your place to go: https://httpd.apache.org/docs/2.4/mod/mod_deflate.html

For nginx: https://docs.nginx.com/nginx/admin-guide/web-server/compression/

like image 174
matiit Avatar answered Sep 23 '22 19:09

matiit