Forum Discussion
Darren_Person_2
Nimbostratus
May 07, 2007Image Leeching / Random querystring fix?
Hi All,
We have the RAMCACHE module installed and are seeing a high rate of evictions. After some further investigation, it appears that we have someone linking to our images using a random...
May 11, 2007
There are several ways you can cleanly add multiple extensions to compare against..pdf
1. Use a switch statement with file globbing (much more optimal than regular expressions.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"*.jpg" -
"*.gif" -
"*.swf" -
"*.pdf" -
"*.xml" {
CACHE::uri [HTTP::host][HTTP::path]
}
}
}I'm not sure how this performs compared to an equivalent set of chained "or" expressions using the ends_with operator. It's most likely fairly equal so I'd go with the approach that is easier to read to you.
2. using a data group (aka class) to contain the extensions and then using the matchclass command to search that list. Only go this route if you need to externalize your list and/or the items in your list number more than 100. It's been calculated that for items under 100 a switch with globbing is a little faster than a matchclass.
bigip.conf rendering on the class
class cache_extensions {
.jpg
.gif
.swf
.xml
}
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::path]] ends_with $::cache_extensions] } {
CACHE::uri [HTTP::host][HTTP::path]
}
}We've got a topic in the wiki that goes over some general rules of thumb for writing fast iRules.
http://devcentral.f5.com/wiki/default.aspx/iRules/HowToWriteFastRules.html
Click hereGood luck and let us know if you find anything interesting during your implementation.
-Joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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