Vacuna - Pre Compression

Pre Compression

In modern times most of the content of a http request get through the network in a compressed form, this is transparently handled by the browser/http-client and server, but this also means the server before sending the content to the user compress it, and for the case of static sites this means compress all the time the same content again and again, this does not make sense!

Vacuna supports the possibility to provide your compressible files in already compressed form, this save some computation power on the server side and maybe in some cases also some disk space.

Here is a simple configuration with support for pre compressed files

server {
    listen "0.0.0.0:80"
    auto "/var/www/" {
        pre_compression "gzip" ".gz"
    }
} 

With the following disk content structure:

└── example.com
    ├── index.html.gz
    ├── other.html.gz
    └── folder
        ├── index.html.gz
        └── page.html.gz

This will automatically check the header for accepted gzip compression read the matching compressed file and send the content, if the client do not provide an accept header that support gzip Vacuna will decompress the file and send it, or eventually re-compress it in a supported format by the client.

It is also possible to define multiple supported compression formats with different extensions, and have also not compressed files, Vacuna will select the preferred compression requested by the client and send that.

The supported compression formats are "gzip", "brotoli", "zstd".