Showing results for 
Search instead for 
Did you mean: 

HowTo: TrafficScript rules processing and flow control

A virtual server may be configured to run several request or response rules. In this case, the rules are executed in turn, unless a terminal action such as connection.close() or pool.use() is called.


Quite often, it's necessary to stop processing a rule and proceed to the next rule. For example, you might have a lengthy rule which only applies to responses that are HTML documents (i.e., not images or other response types):


$contenttype = http.getResponseHeader( "Content-Type" );  
if( string.startsWith( $contenttype, "text/html" ) ) {  


It's more elegant to use the 'break' statement to stop processing the current rule if the condition is not met:


$contenttype = http.getResponseHeader( "Content-Type" );  
if( !string.startsWith( $contenttype, "text/html" ) ) break;  


You can also use the 'continue' statement to restart the current rule.


Read more: Collected Tech Tips: TrafficScript examples

Version history
Revision #:
1 of 1
Last update:
‎02-24-2013 05:44:AM
Updated by:
Labels (1)