Forum Discussion
Ben_Nichols_107
Nimbostratus
Mar 28, 2012RegEx assistance for compression URI list
Apologies if this is a basic question.
Ive been asked to configure a client's F5 to compress specific file type only for a particular site. They have a single virtual server that ...
hoolio
Cirrostratus
Mar 28, 2012Hi Ben,
I think the URI list for compression only includes the URI--not the hostname. So you might need to use an iRule for this to selectively enable or disable compression using COMPRESS::enable|COMPRESS::disable. You could test this with just the profile first. The syntax for the URI list is regex, so you could try www\.sitename\com/.*\.aspx and www\.sitename\com/.*\.js. If either of those work, you could try setting the matching to be case insensitive: (?i)www\.sitename\com/.*\.aspx
If you do need an iRule to implement your logic, here's something you could start testing with. You may need to tweak the logic, but hopefully the major pieces are there to start with.
when HTTP_REQUEST {
Save the path (/path/to/file for www.example.com/path/to/file.ext?param1=value1) for comparison in the response
set path [HTTP::path]
Save the host
set host [string tolower [HTTP::host]]
}
when HTTP_RESPONSE {
Check if this is a text or application/json response
switch -glob [string tolower [HTTP::header Content-Type]] {
"text/*" -
"application/json*" {
Parse the filetype from the requested path
Split off file.ext from /path/to/file.ext
Then use findstr to parse the characters after a period
set filetype [string tolower [findstr [URI::basename $path] . 1]]
if {$filetype ne "" and $host eq "www.example.com"}{
switch $filetype {
aspx -
js {
Enable compression
COMPRESS::enable
Exit the iRule so we do not disable compression below
return
}
}
}
}
}
If we have not enabled compression above, disable it explicitly here
COMPRESS::disable
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects