Pool Based On Extension

Problem this snippet solves:

Requests for various image files go to one pool, pdf's to another, and everything else to a default pool. Example of using switch with a shared script body for multiple options. (The "-" means to execute the next script body if this condition matches.)

Code :

when HTTP_REQUEST {
  # Check the requested path (URI minus the query string)
  switch -glob [HTTP::path] {
    "*.jpg"-
    "*.gif"-
    "*.png"{ pool image_pool }
    "*.pdf"{ pool pdf_pool }
    default{ pool web_pool }
  }
}
Published Mar 18, 2015
Version 1.0
No CommentsBe the first to comment