pub enum Compress {
Never,
IfPrecompressed,
IfWellKnown,
Always,
}
Expand description
When should the server try sending a compressed response?
Variants§
Never
Never compress responses, even if a precompressed response is available.
IfPrecompressed
Only use a compressed response if a precompressed response is available.
With this option, compression won’t be performed “on-the-fly”. This significantly reduces the CPU usage, but will increase the amount of data transferred.
This option will only work with rust-embed-for-web
and only if compression has not been disabled.
With rust-embed
, or if the rust-embed-for-web
resource is tagged with #[gzip = "false"]
this is equivalent to Never.
IfWellKnown
Perform on-the-fly compression if the file mime type is well known to be compressible.
This option allows you to use compression with rust-embed-for-web
when the resource is tagged with #[gzip = "false"]
.
This will use some CPU to compress the file on the fly before responding. Compressed versions are cached in memory.
Always
With this option set, the file is always compressed (as long as the client supports it).
This is usually not a good idea unless you know that all the files embedded are compressible. File formats that are already compressed will not compress any further (such as image or video files), in which case trying to use compression is just a waste of CPU time.