Apache / nginx gzip服务器可以响应,如果它已经分块了吗? [英] Can Apache/nginx gzip server response if it's already chunked?

查看:166
本文介绍了Apache / nginx gzip服务器可以响应,如果它已经分块了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器REST API来回答一些JSON响应。我想在服务器上对其进行分块以增加响应时间。

I have a server REST API that answer some JSON response. I want to chunk it on the server to increase response time.

有没有办法让像Apache或Nginx这样的反向代理或任何其他代理拦截此响应,以及gzip块,并将其作为chunked发送回客户端?

Is there a way for a reverse proxy like Apache or Nginx or any other, to intercept this response, and gzip the chunks, and send it back to the client as chunked?

我通过在我的API服务器中直接分块内容之前解压缩内容而得到了一些工作,我是只是想知道是否还有其他选项可以增加我服务器的响应时间。

I got something working by gzipping the content before chunking it directly inside my API server, and I'm just wondering if there's any other option available to me that would increase response time of my server.

推荐答案

我认为这是可能的根据我见过的其他一些堆栈溢出问题。

I think that this is possible according to some other stack overflow questions that I have seen answered.

https://serverfault.com/questions/159313/enabling-nginx-chunked-transfer-encoding/187573#187573

根据以上所述,可以在你的nginx配置中禁用proxy_buffering,并支持gzipping输出i f配置。

According to the above, it is possible to disable proxy_buffering in your nginx configuration, and supports gzipping output if configured.

如页面中所述,可能存在缺点,您应该进行测试以确保此操作适当。

As noted in the page, there are possible disadvantages and you should test to ensure that this action is appropriate.

这篇关于Apache / nginx gzip服务器可以响应,如果它已经分块了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆