Skip to content

Commit 23ea8ed

Browse files
authored
Explain the streaming headers
1 parent 083b4fa commit 23ea8ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/zip_kit/output_enumerator.rb

+11
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ def each
112112
# but are of a file format built "on top" of ZIPs - such as ODTs, [pkpass files](https://developer.apple.com/documentation/walletpasses/building_a_pass)
113113
# and ePubs.
114114
#
115+
# More value, however, is in the "technical" headers this method will provide. It will take the following steps to make sure streaming works correctly.
116+
#
117+
# * `Last-Modified` will be set to "now" so that the response is considered "fresh" by `Rack::ETag`. This is done so that `Rack::ETag` won't try to
118+
# calculate a lax ETag value and thus won't start buffering your response out of nowhere
119+
# * `Content-Encoding` will be set to `identity`. This is so that proxies or the Rack middleware that applies compression to the response (like gzip)
120+
# is not going to try to compress your response. It also tells the receiving browsers (or downstream proxies) that they should not attempt to
121+
# open or uncompress the response before saving it or passing it onwards.
122+
# * `X-Accel-Buffering` will be set to 'no` - this tells both nginx and the Google Cloud load balancer that the response should not be buffered
123+
#
124+
# These header values are known to get as close as possible to guaranteeing streaming on most environments where Ruby web applications may be hosted.
125+
#
115126
# @return [Hash]
116127
def self.streaming_http_headers
117128
_headers = {

0 commit comments

Comments
 (0)