Forum Discussion
winifred_corbet
Nimbostratus
Aug 18, 2010Dozens of 301 redirects - can we use --- class 301_redirect
We have many irules that handle nothing but 301 redirects, for example, dozens of these types of entries in on irule.
We are looking for a way to streamline and make more efficient irules since we are coming up on a redesign,a nd we will need many more 301 redirects.
Can we use a type of data group list for all these entries? Then remove all these entries from the actual irule?
when HTTP_REQUEST {
if {
[HTTP::uri] equals "/cda//lots-of-stuff-here"
} {
HTTP::respond 301 Location "http://www.website.com/lists/mental.../index.php"
}
elseif {
[HTTP::uri] equals "/cda/verify-specific-url"
} {
HTTP::respond 301 Location ""
}
7 Replies
- hoolio
Cirrostratus
dupe - hoolio
Cirrostratus
Hi Winifred,
Yes, you can store the UR's in datagroups and then use the class command (v10) or the matchclass command (v9) to check the requested URI against the datagroups.
http://devcentral.f5.com/wiki/default.aspx/iRules/class
http://devcentral.f5.com/wiki/default.aspx/iRules/matchclass
Aaron - winifred_corbet
Nimbostratus
How does that work when every
"[HTTP::uri] equals" has a different corresponding "HTTP::respond 301 Location" ? - naladar_65658
Altostratus
I would say if you have less than a hundred of these then putting them into a switch statement would be a really efficient way for the F5 BIG-IP to process it. I have about 80 of these in one switch statement on a high volume VIP and it costs almost nothing computation wise on our 6400 series hardware.when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri] ] { "/cda/lots-of-stuff-here*" { HTTP::respond 301 Location "http://www.website.com/lists/mental.../index.php" } "/cda/verify-specific-url*" { HTTP::respond 301 Location "" } } } - Colin_Walker_12Historic F5 AccountNaladar is right on. Generally speaking I recommend a switch statement up to about 100 or 150 entries, as long as it remains manageable in the code. Past that using a class match is your best bet, and that scales well into the thousands, depending on class structure and content.
Colin - winifred_corbet
Nimbostratus
Definately will use the switch statement for our sites will smaller amounts of redirects. Thanks for that info.
But we also have sites with thousands of redirects.
Can you provide and small example as to what the class match would look like with these types of redirects?
"[HTTP::uri] equals" has a different corresponding "HTTP::respond 301 Location" ? - naladar_65658
Altostratus
In my mind setting up thousands of those using either method is going to be a beast. In this kind of situation (URI matching) Data Groups really are useful when you have several URI's that would use the same 301 Location. So you have a many-to-one mapping with your Data Group. In your situation though it sounds like you have a one-to-one mapping with your Data Groups, meaning one datagroup is only going to match one URI path and then redirect to one 301 Location. I am not certain of the best method in this case.
Something I haven't really done or thought of before, but what if you stacked multiple switch statements on a VIP? If you kept each one under 150 entries would 5 of those on a VIP run faster than one iRule using class match against 1,000 datagroups? If the switches are still faster stacked on top of one another Winifred could create several switch statements, order his URI's alphabetically and label his switches like A-J and K-Z....
I will see if I can type you up a quick example here shortly for the class match command Winifred.
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