Sample TrafficScript Rules
Routing by Content Type
This example inspects the URL in an HTTP request. It decides which pool to send the request to, based on the value of the URL.
Suppose your Web site uses a number of different technologies, including Microsoft ASP pages and Oracle JSP as well as static HTML content. Microsoft Windows based devices serve the ASP pages, Oracle servers handle JSP, and a set of commodity Linux servers serve the static content. You want to direct your traffic to different servers depending on the specific content.
Set up a pool for each of these groups called “windows”, “oracle” and “linux” respectively. The following rule directs network traffic according to the type of content.
$path = http.getPath();
if( string.endsWith( $path, ".jsp" )) {
pool.use( "oracle" );
} else if( string.endsWith( $path, ".asp" )) {
pool.use( "windows" );
} else {
pool.use( "linux" );
}