压缩 HTTP 响应标头?
我在此处和这里但我有些如何跳过HTTP响应部分......我正在寻找一种减少/紧凑的方法我的 HTTP 响应中的标头...
情况是,我正在与远程服务器通信 Java ME 应用程序,任何额外的负担都会导致我损失大量的 $$...
假设客户端和服务器都在我的控制之下,您会建议什么解决方案?
I had asked a few questions regarding compressing HTTP Request headers here and here but I some how skipped the HTTP response part... I am looking for a way to reduce/compact the headers in my HTTP response...
The situation is that I am communicating a Java ME app with a remote Server and any extra baggage is causing me to shed out loads of $$...
Presuming both the client and server are under my control what solution would you'll suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
压缩请求的相同通用机制也适用于响应。再次强调,标头本身不可压缩……只有响应内容可以在符合 HTTP 1.1 的实现中进行压缩。
指定服务器应压缩响应的方法是设置“Accept-encoding”标头,如 HTTP 1.1 规范第 14.3 节中所述。但是,您将受到服务实现的支配,它是否会真正为您压缩响应。如果服务器不能/不会按照您的要求进行压缩,它可能会发送 406 不可接受的响应。或者,一个糟糕的服务器端 HTTP 实现可能会忽略您的 Accept-* 标头并发送未压缩的响应。
The same general mechanisms for compressing requests apply to responses. And once again, the headers themselves are not compressible ... only the response content can be compressed in an HTTP 1.1 compliant implementation.
The way to specify that the server should compress the response is to set an "Accept-encoding" header, as described in section 14.3 of the HTTP 1.1 spec. However, you are at the mercy of the service implementation as to whether it will actually compress the response for you. If the server cannot / will not compress as you have asked, it may send a 406 Not Acceptable response. Alternatively, a crufty server-side HTTP implementation may ignore your Accept-* headers and send the response uncompressed.