1
0
Fork 0
forked from OpenNeo/impress

Configure nginx to send pre-gzipped files to the client

Rails already creates little pre-gzipped `.gz` copies of all our assets
in the `public/assets` directory when we build. This configures nginx to
send those when available!

We weren't doing *any* gzip stuff before, so this helps a lot with those
bigger JS files, like the `wardrobe-2020` stuff. It's now at ~.5MB with
compression, which is still a bit big, but nowhere near as offensive as
the 4.5MB pre-anything, or 1.5MB post-minification, lol.
This commit is contained in:
Emi Matchu 2023-10-25 15:44:01 -07:00
parent 44141ce165
commit 024041e591

View file

@ -17,6 +17,18 @@ server {
root /srv/impress/current/public; root /srv/impress/current/public;
# Serve assets using their precompressed *.gz versions.
# The filenames contain content hashes, so they should be safe to
# cache forever.
# https://stackoverflow.com/a/6952804/107415
location ~ ^/assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
# Try serving static files first. If not found, fall back to the app. # Try serving static files first. If not found, fall back to the app.
try_files $uri/index.html $uri @app; try_files $uri/index.html $uri @app;