Jump to content

Serve precompressed .gz for static assets


Recommended Posts

Suggestion for future IPS vertions.

  1. Put .gz files (with maximum compression level = 9) near all minified static assets.
  2. Add some rules to .htaccess in order to serve this precompressed files for clients who supports compressed assets.


  1. It saves processor time because there is no need to compress assets each time on the fly.
  2. It increases the speed of page loading because precompressed files are much smaller than compressed on the fly.
  3. We can use maximum compression without any downsides because files compressed only once they changed.
Link to comment
Share on other sites

I've actually looked into this before, but the benefits you gain are microscopic. Like, really, really small. Fractions of a millisecond small.

Static resources are also only served once and then cached. Ideally, they're also served over a CDN, not your origin server. Dynamic pages are always compressed on-the-fly and account for most request traffic.

So it sounds like a nice idea and theory, but this is severe micro-optimization and not worth coding into the core software itself. Just use a good CDN like Cloudflare that will take care of doing this for you. Also, use Brotli if you can. Brotli > GZip.

In regards to compression level, using level 9 generally provides no benefit or further compression compares to level 6 and just increases CPU time for decompression as well as compression, so it's not worth using. 6 is the default and the best sweet spot from a practical standpoint.

Link to comment
Share on other sites

It's been a long time since that was implemented and my memory can only hold so much. As I recall, the reasoning was that most server software (i.e. Apache) can handle dynamically gzipping content, but when you store a static asset on S3 it is served as-is, so we had to do it manually ourselves.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...