如何在 Laravel 中 return gzip 压缩 API 响应?
How to return gziped API response in Laravel?
我一般使用这样的响应语法:
return response()
->json(['request'=> $data,
'response' => $response,
'client' => $client], 200);
我怎样才能做到 gzip
ed?
它应该根据网络服务器进行配置。所以这取决于你使用的网络服务器。
如果您使用的是 Apache,mod_deflate 是您要去的地方:https://httpd.apache.org/docs/2.4/mod/mod_deflate.html
对于 nginx:https://docs.nginx.com/nginx/admin-guide/web-server/compression/
我一般使用这样的响应语法:
return response()
->json(['request'=> $data,
'response' => $response,
'client' => $client], 200);
我怎样才能做到 gzip
ed?
它应该根据网络服务器进行配置。所以这取决于你使用的网络服务器。
如果您使用的是 Apache,mod_deflate 是您要去的地方:https://httpd.apache.org/docs/2.4/mod/mod_deflate.html
对于 nginx:https://docs.nginx.com/nginx/admin-guide/web-server/compression/