Do not set variable GZip#mtime but do always set File#mtime #821
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This revisits the discussion in #197 to handle gzipped assets appropriately in the context of web assets.
mtime
header value to a fixed value. By spec this should be0
, but Ruby < 2.7 had a ZLib bug that caused a0
value to be equivalent to unset which results in it being set to the current time. So1
is used instead. The same compromise was just merged into Rack::Deflater.Why
The GZip mtime is a header value of the compressed file; changing the header file changes the contents (content integrity hash) of the file. That's annoying when writing to Docker or Git (#707) that just look at the file contents and can affect caching/cacheability (not strictly Conditional Requests). It's not necessary to set this GZip header to an accurate value. I documented this more over in the Rack::Deflater PR, but briefly:
mod_deflate
sets gzip mtime to0
ngx_http_gzip_module
usesdeflateInit2
with a setting that sets mtime to0
We do want to set the File
mtime
because that is used for setting thelast-modified
http header, and this ensures that the uncompressed source and the compressed file share the samelast-modified
value. This change aligns the lifecycle of the uncompressed and compressed files so that bothlast-modified
and file contents change together.