简体   繁体   English

压缩HTTP响应标头?

[英]Compacting HTTP Response Headers?

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... 我曾在这里这里问过一些有关压缩HTTP请求标头的问题 ,但我了解了如何跳过HTTP响应部分...我正在寻找一种减少/压缩HTTP响应中标头的方法...
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 $$... 情况是我正在与远程服务器通信Java ME应用程序,任何额外的负担都导致我减少了$ ...的负担。
Presuming both the client and server are under my control what solution would you'll suggest? 假设客户端和服务器都在我的控制之下,您会建议什么解决方案?

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. 再一次,标头本身是不可压缩的……只有响应内容可以在符合HTTP 1.1的实现中被压缩。

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. 指定服务器应压缩响应的方法是设置“ Accept-encoding”标头,如HTTP 1.1规范的14.3节所述。 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. 如果服务器无法按照您的要求进行压缩,则可能会发送406 Not Acceptable响应。 Alternatively, a crufty server-side HTTP implementation may ignore your Accept-* headers and send the response uncompressed. 另外,繁琐的服务器端HTTP实现可能会忽略您的Accept- *标头,并以未压缩的方式发送响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM