Search
Joe Pruitt - A Software Architect's take on Network Security
You are here: DevCentral > Weblogs

posted on Wednesday, October 19, 2005 11:11 AM

A user wanted to offload some cache control manipulation from the webserver configuration onto the BIG-IP via iRules. Since this is just HTTP header settings it should be fairly straightforward. We'll, almost...

Trying to write an IRule to make client computers not cache certain file types. We can not have our client computers download any files that start with "slide" or "ps" into their temporary internet files.

I have tried the following however the files are still caching into the Temp internet files.

when HTTP_REQUEST {
  if {[HTTP::uri] contains "slide."} {
    set foundmatch 1
  }
  if {[HTTP::uri] contains "ps."} {
    set foundmatch 1
  } else {
    set foundmatch 0
  }
}
when HTTP_RESPONSE {
  if {$foundmatch == 1} {
    HTTP::header replace Cache-Control no-cache
    HTTP::header replace Pragma no-cache
  }
}

We'll after a bit of packet sniffing it was determined that the browser wasn't honoring the headers since the default response was HTTP/1.0. Fortunately you can easily change this in iRules with the HTTP::version command.

Here's the completed iRule.

when HTTP_REQUEST {
  set foundmatch 0
  if { ([HTTP::uri] contains ".swf") or ([HTTP::uri] contains "ps")} {
    set foundmatch 1
  }
}

when HTTP_RESPONSE {
  if {$foundmatch == 1} {
    HTTP::version "1.1"
    HTTP::header replace Pragma no-cache
    HTTP::header replace Cache-Control no-cache
    HTTP::header replace Expires -1
    HTTP::header remove Connection
    HTTP::header insert Connection Close
  }
}

So, the lesson here is to remember to upgrade the version to 1.1 if you want the browser to honor the no-cache directives B-).

Click here to access the original forum thread.

-Joe

[Listening to: The Boxer - Simon & Garfunkel - Concert in Central Park (06:03)]

Posted In: iRules,

Feedback

9/11/2007 3:43 PM
Gravatar How could I use this to not cache requests from from a machine?

For instance :
Request URI: http://Server1.usac.mycompany.com/incomingdata/postcgi.exe?prefix=brokerreq/&suffix=.csr
Chuck T.

Let Me Know What You Think


Please use the form below if you have any comments, questions, or suggestions.

Title:
 
Name:
 
Email: (so we can show your gravatar)
Website:
Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
 
Please add 1 and 6 and type the answer here:

Blog Stats

Posts:379
Comments:1067
Stories:1
Trackbacks:301
  

Article Categories

  iRules
  

Image Galleries

  

Joe's bookshelf: read

The Lost Gate
4 of 5 stars
This one started slow but I got really got into it about 1/3 of the way through. If you are an Ender's Game fan, you'll probably like this one as well.

goodreads.com


82,243 Members in 102 Countries and Growing!

Join DevCentral Today!

About DevCentral

DevCentral has been a successful, thriving community for many years. We have always strived to bring you the best technical documentation, discussion forums, blogs, media and much more that we can.

So dive in, get familiar with DevCentral. We hope you like it, we hope it makes your job easier, and lets you get that much more power out of the community. To learn more, make sure to check out the Getting Started section. And if you have any problems, or think something could be easier to use, drop us a line to let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback       or