Content type tracking

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

when HTTP_RESPONSE {
   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:

10.0
Published Mar 17, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment