cdepillabout/servant-static-th

Compressed assets

Opened this issue · 2 comments

Hi,

I wonder if it's possible to modify the public API of this library in a way that would allow embedding of compressed assets? The idea is to apply the most aggressive gzip compression on JS/CSS assets as part of a build pipeline, so that they are served directly as gzipped resources without having to spend CPU cycles on on-the-fly encoding.

@avanov I haven't really thought about this, but if you wanted to send a PR implementing this, I'd be happy to merge something like this in.

Although, as I mention in the haddocks, servant-static-th generally isn't intended for high-traffic websites where speed is important. Instead, you'd probably be happier serving your static assets from a CDN.

@cdepillabout thanks, I'll try to come up with an implementation of it.

My use case is different from hight-traffic websites, but I find it suitable even in those scenarios to certain extent, with enough caution.

I'm interested in producing a single static executable bundle, that individuals and organisations would download and run on their private networks as Progressive Web Apps. Having everything packaged into a single binary is extremely appealing in a corporate world as it reduces maintenance/software updates burden.

And the more I think about CDN scenarios, the more I find the same approach appealing there too. For instance, if I put my bundled binary behind CloudFlare CDN, it will be able to automatically request and cache the assets it receives from my app's endpoints, given my backend is able to prove the static nature of the assets. Certain CDNs can then automatically distribute the cached assets across several regions.