Compressing large string in ruby
问题 I have a web application(ruby on rails) that sends some YAML as the value of a hidden input field. Now I want to reduce the size of the text that is sent across to the browser. What is the most efficient form of lossless compression that would send across minimal data? I'm ok to incur additional cost of compression and decompression at the server side. 回答1: You could use the zlib implementation in the ruby core to in/de-flate data: require "zlib" data = "some long yaml string" * 100