Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Problem this snippet solves:

Have you ever wondered what types of content are served by your web servers? Have you wondered how many requests could be offloaded to the BIG-IP if you added the RAM Cache module? Or maybe how much acceleration you may get from WebAccelerator? Try out this iRule. Most of the time everything other than the HTML pages should be cacheable.

How to use this snippet:

This iRule requires LTM v10. or higher.

Code :

# First, create statistics profile named "ContentType" with following entries:
#   HTML
#   Images
#   Scripts
#   Documents
#   Stylesheets
#   Other
# Now associate this Statistics Profile to the virtual server.  Then apply the following iRule.
# To view the results, go to Statistics -> Profiles - Statistics

   switch -glob [HTTP::header "Content-type"] {
      "image/*"         { STATS::incr "ContentType" "Images" }
      "text/html"       { STATS::incr "ContentType" "HTML" }
      "text/css"        { STATS::incr "ContentType" "Stylesheets" }
      "*javascript"     -
      "text/vbscript"   { STATS::incr "ContentType" "Scripts" }
      "application/pdf" -
      "application/msword" -
      "application/*powerpoint" -
      "application/*excel" { STATS::incr "ContentType" "Documents" }
      "default"         { STATS::incr "ContentType" "Other" }

Tested this on version:

Version history
Last update:
‎17-Mar-2015 12:17
Updated by: