Subscribe to receive notifications of new posts:

An All New (and Improved) AutoMinify

2011-06-18

2 min read
An All New (and Improved) AutoMinify

We turned on AutoMinify as a beta feature a while ago, but we weren't particularly happy with it. Originally, we did it the same way everyone else does: we'd request the resource from the origin, serve it unminified on the first load, cache it, and then, if it was CSS or Javascript, run a process that minified it and replaced the cached version on the server. Seems sensible enough, but it's a bad approach.

To begin, this minification strategy doesn't work well for highly dynamic content, forcing website owners to have to go back and expire the cache whenever anything changed. For CSS and Javascript that can work, but it's a disaster for dynamic HTML. The second issue is less obvious: most minification resources don't work at our scale. We tried every minification library available, and a few non-public ones that were developed in-house by friends at some of the Internet giants, and none of them worked as efficiently as we wanted when we're minify many millions of files across twelve (and soon many more) data centers.

We were bummed because minification does provide some measurable benefit. Generally, for text based resources, our tests showed minification got about a 10% benefit when combined with our aggressive GZIP compression over just GZIP compression alone. All else being equal, if you can make a resource 10% as big it's as good as making the Internet connection 10% faster. It's not a huge win, since most bytes that make up the typical website aren't in text-based resources that can be minified. However, we believe every millisecond matters, so we looked for another way.

Unsatisfied with any of the existing minification resources, we decided to develop our own. Last week we quietly turned on a new minification process that was written to overcome the two challenges previous minification strategies had faced. First, it works in-line in the response stream, much like GZIP, which means it doesn't force you to cache content in order to get the benefit. Second, it's extremely fast. Written from the ground up to perform at line speed and is easily 100x as fast as the next closest competitor.

AutoMinify included free with any plan, and you can choose whether you want to minify CSS, Javascipt, HTML (even dynamic HTML), or any combination of the three. You can turn Auto Minify on or off via your CloudFlare Settings control panel with a single click and the settings take effect nearly instantly (because you don't have to wait for the flawed cache-and-store approach). Next up for the engineering wizards behind this: a radically better approach to image optimization.

Cloudflare's connectivity cloud protects entire corporate networks, helps customers build Internet-scale applications efficiently, accelerates any website or Internet application, wards off DDoS attacks, keeps hackers at bay, and can help you on your journey to Zero Trust.

Visit 1.1.1.1 from any device to get started with our free app that makes your Internet faster and safer.

To learn more about our mission to help build a better Internet, start here. If you're looking for a new career direction, check out our open positions.
Speed & ReliabilityAutoMinifyJavaScript

Follow on X

Matthew Prince|@eastdakota
Cloudflare|@cloudflare

Related posts

October 09, 2024 1:00 PM

Improving platform resilience at Cloudflare through automation

We realized that we need a way to automatically heal our platform from an operations perspective, and designed and built a workflow orchestration platform to provide these self-healing capabilities across our global network. We explore how this has helped us to reduce the impact on our customers due to operational issues, and the rich variety of similar problems it has empowered us to solve....

September 25, 2024 1:00 PM

Introducing Speed Brain: helping web pages load 45% faster

We are excited to announce the latest leap forward in speed – Speed Brain. Speed Brain uses the Speculation Rules API to prefetch content for the user's likely next navigations. The goal is to download a web page to the browser before a user navigates to it, allowing pages to load instantly. ...