-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
md5 hash changes multiple times #36
base: master
Are you sure you want to change the base?
Conversation
…ic_image.png), etc can be changed multiple times: Original -> A -> B -> C. Old version compressed file A based on a hash of Original, so web server should generate gz files from C on fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are more than one changes in this PR. Please consider splitting the PR.
@@ -34,7 +35,7 @@ def __init__(self, *args, **kwargs): | |||
self.allowed_extensions = getattr(settings, "STATIC_COMPRESS_FILE_EXTS", ["js", "css", "svg"]) | |||
self.compress_methods = getattr(settings, "STATIC_COMPRESS_METHODS", DEFAULT_METHODS) | |||
self.keep_original = getattr(settings, "STATIC_COMPRESS_KEEP_ORIGINAL", True) | |||
self.minimum_kb = getattr(settings, "STATIC_COMPRESS_MIN_SIZE_KB", 30) | |||
self.minimum_kb = getattr(settings, "STATIC_COMPRESS_MIN_SIZE_KB", 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not ok with changing this. Compressing everything make building slower and it is not always smaller.
If you want deterministic file hash from your web server, either fix the web server or change the library's configuration value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question here is. should I make it once or let my web server do it for me multiple times.
look at output of:
# strace -p $NGINX_WORKER_PID 2>&1 | grep .gz
On this art of errors generates nginx .gz file on fly if gzip = on;
is set.
if not, so error 404 will be sent.
Edit: precondition for e404 here gzip_static = on;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can either turns gzip off in your web server, or set STATIC_COMPRESS_MIN_SIZE_KB=0 in your site's configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, its right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but with >0 not to exclude that it comes to the 404 error with default settings. so consider the user your module faulty and uninstall it:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you hardcoding .gz/.br in your page?
The installation guide recommends that your web server should be configured to serve precompressed files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I am using CompressedManifestStaticFilesStorage
und yes gzip_static
is on
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If gzip
is off
, i get 404 because requested file is C.hashC.css
but exists as gzipped only A.OriginalHash.css
A, B are intermediate und C final versions of a certain file.
if dry_run: | ||
return | ||
|
||
files = OrderedDict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear why this file has to be changed, based on the pull request's description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at super() class. with --dry-run no files are generated
generator = iter((f, f, False) for f in paths) | ||
|
||
for file, hashed_file, processed in generator: | ||
files[file] = hashed_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not exactly clear what this is doing. Consider adding commenting.
I'm guessing that it is to not process files that are not emitted by super class. If possible please consider splitting this to another PR so we can review this easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure here.
a super class must not have a post_process() method implemented. so you have to take in this case the whole fileset, that have not been post_processed
for name in paths.keys(): | ||
if not self._is_file_allowed(name): | ||
if not (name in files and self._is_file_allowed(name)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if name not in files or not self._is_file_allowed(name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a matter of taste and legibility :)
md5 hash of static files containing @include another static, url(static_image.png), etc can be changed multiple times:
Original -> A -> B -> C.
Old version compressed file A based on a hash of Original, so web server tried to get .hash-C.ext.gz file, could not find it and generated it on fly from hash-C.ext
default STATIC_COMPRESS_MIN_SIZE_KB changed to 0. nginx server always tries to get .gz file regardless of the size