Forum Discussion
RegEx 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 multiple sites are published through (using host headers on the web servers). The virtual server has an http profile that enables content compression for application/json. Ive now been asked to enable compression for *.aspx, *.js and *.css but only for one specific site that is published through the virtual server (dont ask me why, this is what I have been asked to do).
I was hoping to add entries like the following to the URI include list:
*www.sitename.com/*.aspx
*.www.sitename.com/*.js
etc
I cant work out the required format of regular expression. Or am I being dumb on this occasion?
My only other solution would be to create a new virtual server on a seperate IP, but I want to avoid that. Or I guess there are iRules, but I thought this would be simple.
Many thanks in advance.
Ben
- hoolio
Cirrostratus
Hi Ben,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 }
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