Cache_control_iRules

Problem this snippet solves:

Description of HTTP1.1 Cache-control headers and how to manipulate them with iRules, including case by case examples. Regards, Dave Seddon dave@seddon.ca

Code :

# Remove Cache-Control Headers 

when HTTP_RESPONSE { 
   # Remove all Cache-Control related headers 
   HTTP::header remove Cache-Control 
   HTTP::header remove Expires
   HTTP::header remove Pragma  
}

# Replace Cache-Control Headers - This will cache for 5 minutes 

when HTTP_RESPONSE { 
   # Remove all Cache-Control related headers 
   HTTP::header replace Cache-Control public,max-age=300
   HTTP::header remove Expires
   HTTP::header remove Pragma  
}

# Replace Cache-Control Headers - This will NOT cache 

when HTTP_RESPONSE { 
   # Remove all Cache-Control related headers 
   HTTP::header replace Cache-Control private,no-cache,no-store,max-age=0
   HTTP::header replace Expires -1
   HTTP::header replace Pragma no-cache
}
Published Mar 16, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment