Skip to content

Instantly share code, notes, and snippets.

@TobiX
Last active January 3, 2025 10:53
Show Gist options
  • Save TobiX/9daa43186bcd80071fcfe726f91c9bc6 to your computer and use it in GitHub Desktop.
Save TobiX/9daa43186bcd80071fcfe726f91c9bc6 to your computer and use it in GitHub Desktop.

Revisions

  1. TobiX revised this gist Apr 24, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@ This needs a directory with 3 precompressed files, which may be created like thi
    more/less bandwith to spare or want to annoy "visitors" more/less):

    ```sh
    dd if=/dev/zero bs=1M count=10240 | gzip -9 > 42.gzip
    dd if=/dev/zero bs=1M count=102400 | brotli > 42.br
    dd if=/dev/zero bs=1M count=102400 | zstd -9 -T0 > 42.zstd
    dd if=/dev/zero bs=1M count=10240 status=progress | gzip -9 > 42.gzip
    dd if=/dev/zero bs=1M count=102400 status=progress | brotli > 42.br
    dd if=/dev/zero bs=1M count=102400 status=progress | zstd -9 -T0 > 42.zstd
    ```

    I got these compression ratios:
  2. TobiX revised this gist Feb 8, 2024. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Caddyfile
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,10 @@
    vars @is_br compression br
    @is_zstd header Accept-Encoding *zstd*
    vars @is_zstd compression zstd
    header Content-Encoding {vars.compression}
    header {
    Content-Encoding {vars.compression}
    Content-Type "text/html; charset=utf-8"
    }
    rewrite * /42.{vars.compression}
    file_server
    }
  3. TobiX revised this gist Feb 8, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ dd if=/dev/zero bs=1M count=102400 | zstd -9 -T0 > 42.zstd
    I got these compression ratios:

    File | Compressed | Uncompressed
    --------|------------|-------------
    42.gzip | 9.937 MiB | 10 GiB
    42.br | 82.032 KiB | 100 GiB
    42.zstd | 3.17 MiB | 100 GiB
  4. TobiX created this gist Feb 8, 2024.
    16 changes: 16 additions & 0 deletions Caddyfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # Tar pit
    @shit {
    path */.env
    path /wp-login.php
    }
    handle @shit {
    root * /srv/www
    vars compression gzip
    @is_br header Accept-Encoding *br*
    vars @is_br compression br
    @is_zstd header Accept-Encoding *zstd*
    vars @is_zstd compression zstd
    header Content-Encoding {vars.compression}
    rewrite * /42.{vars.compression}
    file_server
    }
    18 changes: 18 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    This is a silly snippet of caddy config file to send heavily compressed huge files to clients prodding "stupid" URLs.
    (idea from https://tech.lgbt/@becomethewaifu/111879788755441482)

    This needs a directory with 3 precompressed files, which may be created like this (tune numbers if you have
    more/less bandwith to spare or want to annoy "visitors" more/less):

    ```sh
    dd if=/dev/zero bs=1M count=10240 | gzip -9 > 42.gzip
    dd if=/dev/zero bs=1M count=102400 | brotli > 42.br
    dd if=/dev/zero bs=1M count=102400 | zstd -9 -T0 > 42.zstd
    ```

    I got these compression ratios:

    File | Compressed | Uncompressed
    42.gzip | 9.937 MiB | 10 GiB
    42.br | 82.032 KiB | 100 GiB
    42.zstd | 3.17 MiB | 100 GiB