Skip to content

Add pre-flush hook, and use that to implement brotli compression #45

@zigster64

Description

@zigster64

Pro: applying brotli compression on stream output is a big win, with massive performance gains over the network.

Con: adding brotli pulls in a C dependency, making builds of the SDK not as simple as a pure zig approach. Brotli is a lot of code, due to the massive static table.

Con++: adding extra deps at the library level is very not nice. The C dependency might not even compile on some platforms even.

Proposed solution: add a pre-write hook to the SDK. If null, just flushes the contents of the write buffer, no brotli. If the user wants brotli, then create a pre-write hook, and apply brotli compression to whatever is in the write buffer. Benefit of this is that the external dependency for the brotli lib is pulled in as part of the user’s app dependencies… Not an integral dependency that the SDK pulls in whether you like it or not.

User can then define arbitrarily large buffers to improve compression performance to suit whatever HTML streams they are generating.

Add a simple example program to demonstrate how to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions