Zip html content for extra speed

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-04-25

By default, my web application only returned uncompressed HTML. Relying on third party data ( I didn't this test myself ), I slowed down my site by 15% through omitting to zip the HTML.

Fortunately, this was easily fixed:

# application.rb
config.middleware.use Rack::Deflater

How to confirm it works? Look for the header Content-Encoding=gzip of a HTML request in DevTools

References