Forum Discussion
Sectively compression for url using “*.uif”.
Hi all,
I need help on writing iRule for selectively compressing as in the below. This is one of acceleration requirements from an liability insurance company for mobile T/F(migrating core insurance system for mobile users).
1) Compress all HTTP responses except for compressed contents such as images.
2) Selectively compress for url using “*.uif”.
a) If content-encoding of HTTP response is “gzip”, then no compression needed.
b) Compress all others.
My first answers:
Must set the Compression to "Selective" in the profile
rule selective_compress_enable {
when HTTP_REQUEST {
if { ([HTTP::uri] eq "*.uif") and ([HTTP::header value Content-Encoding] eq "gzip") } {
log local0. "compression_rule_disable : *.uif & gzip"
COMPRESS::disable
}
else {
COMPRESS::enable
}
}
}
I am very new to iRule and I'd like to have help on this.
Thanks in advance,
Neo
- hoolioCirrostratusHi Neo,
when HTTP_REQUEST { Prevent response compression if request is for a uif filetype switch -glob [HTTP::path] { "*.uif" { set compress 0 } default { set compress 1 } } } when HTTP_RESPONSE { Enable compression if request was not for a uif filetype, the response isn't already compressed and the response is text-based if {$compress and [HTTP::header Content-Encoding] ne "gzip" and [HTTP::header Content-Type] contains "text"}{ COMPRESS::enable } }
- Hello Aaron,
- hoolioCirrostratusI guess you could do this with a custom HTTP profile. The URI checks and content-types can be configured. If the pool members use compression, you could prevent this by setting the Request Header To Erase to 'Accept-Encoding'. This would be simpler and more efficient than an iRule.
- So it sounds like we would only need to enable IRule compression if we are trying to do complex logic compression, but if we are just compressing by the content types of static files we should just do it using HTTP Profiles at the Virtual Server Level. Aaron, when you say:
- hoolioCirrostratusSo it sounds like we would only need to enable IRule compression if we are trying to do complex logic compression, but if we are just compressing by the content types of static files we should just do it using HTTP Profiles at the Virtual Server Level.
- So you mean if one does NOT want to compress an certain type of file, then just remove the "Accept-Encoding" header from the http request. I like it. :)
- hoolioCirrostratusThat's it. If you remove the Accept-Encoding header via the HTTP profile it will be removed from all requests. If you want to do this by the requested file type, you'd need to use an iRule.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com