Skip to content

Compress middleware should not compress image/* content types #2981

@nyurik

Description

@nyurik

Expected Behavior

Most image/* mime types such as png and jpeg are already pre-compressed, so when using .wrap(middleware::Compress::default()), the expectation is that the well known images would not be compressed.

Current Behavior

Currently the compression middleware only looks at the content-encoding of the response (which should not be set for images), and thus compresses images again.

Possible Solution

  • Check against a list of well known image types
  • Offer a way to set a callback so that the user can check themselves
  • all of the above?

Your Environment

  • Rust Version: 1.67.1
  • Actix Web Version: 4.3.0

Metadata

Metadata

Assignees

Labels

A-webproject: actix-webC-improvementCategory: an improvement to existing functionalitygood-first-issueeasy to pick up for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions