diff --git a/changes/changelog.d/front-performance.enhancement b/changes/changelog.d/front-performance.enhancement new file mode 100644 index 0000000000000000000000000000000000000000..03ca0e47861919cf8f8980c7e24481cc0f86da7f --- /dev/null +++ b/changes/changelog.d/front-performance.enhancement @@ -0,0 +1,51 @@ +Improved front-end performance by stripping unused dependencies, reducing bundle size +and enabling gzip compression + +Enable gzip compression [manual action suggested] +------------------------------------------------- + +Gzip compression will be enabled on new instances by default +and will reduce the amount of bandwidth consumed by your instance. + +If you with to benefit from gzip compression on your instance, +edit your reverse proxy virtualhost file (located at ``/etc/nginx/sites-available/funkwhale.conf``) and add the following snippet +in the server block, then reload your nginx server:: + + server { + # ... exiting configuration + + # compression settings + gzip on; + gzip_comp_level 5; + gzip_min_length 256; + gzip_proxied any; + gzip_vary on; + + gzip_types + application/atom+xml + application/javascript + application/json + application/ld+json + application/activity+json + application/manifest+json + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/bmp + image/svg+xml + image/x-icon + text/cache-manifest + text/css + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; + # end of compression settings + } diff --git a/deploy/docker.proxy.template b/deploy/docker.proxy.template index 319f287e79ca21a62a6c00884bbec3d54d2639b3..812027bfa3b1574e41eaba7ec2a1a2110e0c476e 100644 --- a/deploy/docker.proxy.template +++ b/deploy/docker.proxy.template @@ -29,6 +29,40 @@ server { # HSTS add_header Strict-Transport-Security "max-age=31536000"; + # compression settings + gzip on; + gzip_comp_level 5; + gzip_min_length 256; + gzip_proxied any; + gzip_vary on; + + gzip_types + application/atom+xml + application/javascript + application/json + application/ld+json + application/activity+json + application/manifest+json + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/bmp + image/svg+xml + image/x-icon + text/cache-manifest + text/css + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; + location / { include /etc/nginx/funkwhale_proxy.conf; proxy_pass http://fw/; diff --git a/deploy/nginx.template b/deploy/nginx.template index b81ecc61af40e05736de7051fff3a575764a0f3d..702dc05eeef7a4b48c0149e5a0eba9933ad8e066 100644 --- a/deploy/nginx.template +++ b/deploy/nginx.template @@ -43,6 +43,41 @@ server { root ${FUNKWHALE_FRONTEND_PATH}; + # compression settings + gzip on; + gzip_comp_level 5; + gzip_min_length 256; + gzip_proxied any; + gzip_vary on; + + gzip_types + application/atom+xml + application/javascript + application/json + application/ld+json + application/activity+json + application/manifest+json + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/bmp + image/svg+xml + image/x-icon + text/cache-manifest + text/css + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; + + # end of compression settings location / { include /etc/nginx/funkwhale_proxy.conf; # this is needed if you have file import via upload enabled diff --git a/docker/nginx/conf.dev b/docker/nginx/conf.dev index 297cfa509663121c2b4589e19b9aaaefb6d48775..3e7a3515a6d9b81fb3a95c348f5f51de899879be 100644 --- a/docker/nginx/conf.dev +++ b/docker/nginx/conf.dev @@ -43,6 +43,39 @@ http { charset utf-8; client_max_body_size 30M; include /etc/nginx/funkwhale_proxy.conf; + # compression settings + gzip on; + gzip_comp_level 5; + gzip_min_length 256; + gzip_proxied any; + gzip_vary on; + + gzip_types + application/atom+xml + application/javascript + application/json + application/ld+json + application/activity+json + application/manifest+json + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/bmp + image/svg+xml + image/x-icon + text/cache-manifest + text/css + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy; location /front/ { proxy_pass http://funkwhale-front/front/;