This PR contains the work done to add response compression to the Website service by registering the `ResponseCompressionMiddleware` middleware so responses are compressed when the client advertises support and the body exceeds a minimum size. To provide further details about the work done: * Added the **HummingbirdCompression** package dependency. * Integrated the `ResponseCompressionMiddleware` middleware into the router, ahead of the not-found and static file middleware. * Made the `minimum-response-size-to-compress` threshold configurable, with a default. Reviewed-on: rock-n-code/loud-amsterdam#7 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
17 lines
786 B
Swift
17 lines
786 B
Swift
extension Int {
|
|
/// A namespace for the cache's default configuration values.
|
|
public enum Cache {
|
|
/// The default max-age, in seconds, applied to text-based static files (1 hour).
|
|
public static let maxAgeText = 3_600
|
|
/// The default max-age, in seconds, applied to image static files (1 week).
|
|
public static let maxAgeImage = 604_800
|
|
/// The default max-age, in seconds, applied to all other static files (1 day).
|
|
public static let maxAgeDefault = 86_400
|
|
}
|
|
/// A namespace for the response compression's default configuration values.
|
|
public enum Compression {
|
|
/// The default minimum response body size, in bytes, before compression is applied (1 KB).
|
|
public static let minResponseSize = 1_024
|
|
}
|
|
}
|