-
Notifications
You must be signed in to change notification settings - Fork 152
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
Skip compression of already compressed files #347
base: main
Are you sure you want to change the base?
Conversation
@evansd Any updates on this? |
c413e16
to
d2cd64c
Compare
@lapinvert @adamchainz I have rebased this to the current Also this would be very easily achieved when #354 is merged by simple |
To me it sounds a no-brainer feature to have. For projects with many static files it makes a huge difference. |
@@ -82,14 +82,14 @@ def compress(self, path): | |||
stat_result = os.fstat(f.fileno()) | |||
data = f.read() | |||
size = len(data) | |||
if self.use_brotli: | |||
if self.use_brotli and not os.path.isfile(f"{path}.br"): |
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 file names are only unique when using the CompressedManifestStaticFilesStorage
backend.
When using the CompressedStaticFilesStorage
backend, this would cause WhiteNoise to never re-compress a file, even if its contents have changed
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, exactly. And unfortunately, in the default config, the non-MD5-hashed names are left around and can still be served... This needs some more involved consideration, and tests.
New take on #296