Skip to content

Static compression should not be dependent on the compression features #362

@palant

Description

@palant

Search for duplicate feature request

  • I already searched, and this feature request or improvement is not a duplicate.

Feature scope

Improve existing functionality

Feature request related to a problem

As things are now, static compression chooses which compression types to support based on compression features. This makes little sense given that compression features activate dependencies that static compression doesn’t use. It also means that static compression is occasionally unused when it really should be: Accept-Encoding: br, gzip results in SWS only looking for a pre-compressed Brotli file. If it doesn’t exist, the existing gzip file is ignored.

Describe the solution you'd like

Static compression should either be available unconditionally (only behind the configuration setting) or behind a compression-static feature. As it doesn’t introduce any dependencies, the former should be preferable.

Rather than using compression::get_preferred_encoding(), static compression should call AcceptEncoding::sorted_encodings() directly. For each encoding returned, it should check whether a file with the corresponding extension exists – use it if present, check next encoding if not.

Optionally, a new configuration option could be introduced to restrict the encodings to be considered, encodings not on this list would be skipped over. This is to avoid hitting the file system unnecessarily (e.g. Accept-Encoding: br, deflate, zstd, gzip, yet the directory is known to only contain gzip files).

Describe alternatives you've considered

Build target

All targets

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededv2v2 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions