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

Implement gzipping for static file serving #261

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

wwwillchen
Copy link
Collaborator

@wwwillchen wwwillchen commented May 16, 2024

  • Fixes Serve static assets (e.g. JS, CSS) using gzip #231
  • This produces a significant size savings, particularly for the JS bundle (~4x: 1.6MB -> 400kb for prod mode).
  • Although ideally gzipping is handled outside of the Flask server and at another layer (e.g. a web server like NGINX), there's benefits to doing it in the Flask app because in development use case, particularly with Colab, it can be quite slow to load the JS bundle.
  • To avoid paying the cost of gzipping the same files over and over again (~30ms on my local computer), this implements a singleton cache. This is OK assuming that the file contents of what we're caching do not change (for these static files, this should hold true).

@wwwillchen wwwillchen changed the title WIP: Implement gzipping Implement gzipping for static file serving May 16, 2024
@wwwillchen wwwillchen requested a review from richard-to May 16, 2024 07:39
Copy link
Collaborator

@richard-to richard-to left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wwwillchen wwwillchen merged commit 8aa3e0c into google:main May 16, 2024
3 checks passed
@wwwillchen wwwillchen deleted the i231 branch May 16, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serve static assets (e.g. JS, CSS) using gzip
2 participants