简体   繁体   English

如何从CouchDB的HTTP响应中压缩JSON内容?

[英]How can I compress the JSON content from CouchDB's HTTP responses?

I am making a lot of _all_docs requests to CouchDB's HTTP server. 我正在向CouchDB的HTTP服务器发出很多_all_docs请求。 One thing I'm realizing is that the data is not compressed, so this results in large file sizes. 我意识到的一件事是数据没有被压缩,因此导致文件大小。 Even by using limit and skip, the files can sometimes be 10MB each. 即使使用限制和跳过,文件有时也可以是10MB。 That doesn't cause any problems for my app, but it does mean that if a connection to our CouchDB server is slower than our office connection, it will go rather slow. 这不会对我的应用程序造成任何问题,但它确实意味着如果与我们的CouchDB服务器的连接比我们的办公室连接慢,它将变得相当慢。

Is there any way I can enable HTTP compression? 有什么办法可以启用HTTP压缩吗? I am not referring to attachments - just the JSON files. 我不是指附件 - 只是JSON文件。

Also, I am using Windows Server - not Linux/Unix. 另外,我使用的是Windows Server - 而不是Linux / Unix。

Thanks! 谢谢!

There is no support in CouchDB directly, but it has been requested . CouchDB中没有直接支持,但已被请求 (so voice your support there if you want this included) (如果你想要这个,请在​​那里发表你的支持)

That being said, there are a number of options you have. 话虽这么说,你有很多选择。 First, you can set up nginx as a reverse proxy and allow it to compress (and possibly cache) responses for you. 首先,您可以将nginx设置为反向代理,并允许它为您压缩(并可能缓存)响应。 After a quick search, I found this plugin that you install in CouchDB directly. 快速搜索后,我发现你直接在CouchDB中安装了这个插件

Another thing is that CouchDB does a pretty solid job of allowing clients to cache reliably. 另一件事是CouchDB在允许客户端可靠缓存方面做得非常可靠。 You can leverage this to prevent repeatedly downloading the same large resource. 您可以利用此功能来防止重复下载相同的大型资源。

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

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