-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
🗂️ fix: Disable express-static-gzip
for Uploaded Images
#8307
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
Conversation
Thanks! Does it make sense to default |
It does, but the behavior would be different from what we have now. |
@danny-avila I changed the default in a new commit and updated the documentation. |
express-static-gzip
for Uploaded Images
…a#8307) * Fix scanning of the uploaded images folder on startup * Re-write tests to pass linting * Disable image output gzip scan by default * Add `ENABLE_IMAGE_OUTPUT_GZIP_SCAN` to `.env.example`
…a#8307) * Fix scanning of the uploaded images folder on startup * Re-write tests to pass linting * Disable image output gzip scan by default * Add `ENABLE_IMAGE_OUTPUT_GZIP_SCAN` to `.env.example`
…a#8307) * Fix scanning of the uploaded images folder on startup * Re-write tests to pass linting * Disable image output gzip scan by default * Add `ENABLE_IMAGE_OUTPUT_GZIP_SCAN` to `.env.example`
…a#8307) * Fix scanning of the uploaded images folder on startup * Re-write tests to pass linting * Disable image output gzip scan by default * Add `ENABLE_IMAGE_OUTPUT_GZIP_SCAN` to `.env.example`
Summary
The main change is to add an environment variable
DISABLE_IMAGES_OUTPUT_STATIC_CACHE
to skip the delivering of uploaded images throughexpress-static-gzip
if set totrue
.Why do we need this?
In production, we have over 100k uploaded images mounted from a network drive.
On startup,
express-static-gzip
scans this folder to find gzipped versions of each image.This can take multiple minutes on each startup.
There is no existing gzipped images in the folder, so this is completely unnecessary.
Why fix it like this?
This PR maintains the previous behavior if
DISABLE_IMAGES_OUTPUT_STATIC_CACHE
is not set.An alternative would be to never use
express-static-gzip
for the image output folder.The library does not compress the images, it only serves pre-compressed ones.
If this is the approach we prefer (it would simplify the code), it is easy to modify this PR, the added tests should make the behavior difference more obvious.
The original PR that introduced
express-static-gzip
likely for static assets only as there is no mechanism to automatically gzip uploaded images.It included vite configuration code for assets
that was updated in this PR.
Note: I will add the environment variable to the documentation once we decide on its necessity.
Change Type
Testing
Added extensive unit tests.
Checklist
Please delete any irrelevant options.