Skip to content
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

Serve static assets GZIPed #143

Open
t-muehlberger opened this issue Sep 26, 2023 · 4 comments
Open

Serve static assets GZIPed #143

t-muehlberger opened this issue Sep 26, 2023 · 4 comments
Labels
area:backend Related to the server component class:newcomer Good for newcomers to the project: easy and/or limited scope prio:C Nice to have, but optional state:postponed Deemed low priority type:enhancement New feature or request

Comments

@t-muehlberger
Copy link
Collaborator

Is there a simple way in FastAPI to serve static assets with GZIP compression when the browser supports it? Looking at the estimates generated by the Angular build tool I think this would make sense.

If there is no simple way to enable this in the python backend the optimization should probably be deferred to the reverse-proxy or CDN.

Definitely not a high priority optimization, just putting this here so it won't be overlooked in the future.

grafik

@t-muehlberger t-muehlberger added type:enhancement New feature or request state:postponed Deemed low priority area:backend Related to the server component labels Sep 26, 2023
@jbethune
Copy link
Collaborator

When I look at https://fastapi.tiangolo.com/advanced/middleware/?h=gzip#gzipmiddleware then this seems to be fairly easy to implement. @scy what do you think?

@scy
Copy link
Collaborator

scy commented Sep 30, 2023

This looks to me as if it’ll do the gzip compression on the fly, with no server-side caching of the compressed data whatsoever. I’m not a fan. We shouldn’t compress the files again for every request.

@jbethune
Copy link
Collaborator

jbethune commented Oct 3, 2023

It looks like chatcontrol.dearmep.eu is running with nginx. Maybe the ngx_http_gzip_static_module solves our problem? According to this Stack Overflow answer we would need to create foo.gz for every file foo that we want to send in gzipped form.

@t-muehlberger
Copy link
Collaborator Author

@jbethune I don't know the details of our deployment but I am guessing that Nginx only acts as a reverse proxy and the files are still served by the python backend. We would probably need to make changes to our deployment so that Nginx serves the static files directly then this would work.

But I think we should not spend too much time on this issue now, this is an optimization that we can easily add after the release.

@scy scy added the prio:D Completely optional, but interesting nevertheless label Oct 11, 2023
@scy scy added class:newcomer Good for newcomers to the project: easy and/or limited scope prio:C Nice to have, but optional and removed prio:D Completely optional, but interesting nevertheless labels Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:backend Related to the server component class:newcomer Good for newcomers to the project: easy and/or limited scope prio:C Nice to have, but optional state:postponed Deemed low priority type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants