Jump to content

Community

Mr 13

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.
Edited by Mr 13

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

@bfarber, why only for S3? I hope to see this available for any environment. Thanks.

In my experience benefits of this approach are huge for users with slow connection, especially mobile users.

Edited by Mr 13

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

But apache and nginx could be easily configured to use pre-compressed files instead of dynamic gzipping, so i hope it will be changed. Thank you!

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy