Skip to content

Allow setting compression levels #2928

Open
@bubelov

Description

@bubelov

Expected Behavior

Although the default compression levels are sane, some users might want to adjust it to better fit their needs. Being able to set the compression levels gives users more control and flexibility.

Current Behavior

.wrap(Compress::default())

That's super easy to add, but there are no ways to fine-tune the compression algos.

Possible Solution

I like the defaults, although the available compression algos aren't that transparent, in a sense that it's tricky to figure out which ones are going to be supported from looking at the init code alone. I think that keeping it that way is fine, but it would be nice to have an alternative way to configure compression, here is a pseudo-code:

.wrap(Compress::setup(
    vec![
        Gzip::Level_5,
        Brotli::Level_7,
    ]
))

I'm relatively new to Rust, so take it with a grain of salt, I'm sure there are some more convenient/idiomatic patterns which can be used to setup the compression levels.

Context

I'm fine with the current defaults but I have some spare CPU capacity so it wouldn't hurt to keep it busy. Also, I'm planning to add Tor support to one of the APIs I'm working on, so optimizing for bandwidth would certainly help to speed things up a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-httpproject: actix-httpA-webproject: actix-webC-improvementCategory: an improvement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions