Forum Discussion

Matthew_Goche_6's avatar
Matthew_Goche_6
Icon for Nimbostratus rankNimbostratus
Feb 22, 2007

Problems encouraging caching on the browser

We are a web-hosting site and we have an iRule setup to encourage caching on the client browsers. However, a lot of URIs that meet the iRule arguments are not being cached by clients running IE6.0. A specific URI that we are having trouble with is:

 

 

/imageserver/plumtree/common/private/js/jsutil/LATEST/PTUtil.js

 

 

Please let me know is there are any other considerations for this work. Some smaller files seem to be cached, but I know my cache limit is not the problem. Please let me know if you have any ideas.

 

 

The iRule is:

 

 

when HTTP_REQUEST priority 50 {

 

set cachetime 0

 

 

if {not ([HTTP::version] equals "1.1")} {

 

HTTP::header insert "x-httpversion" [HTTP::version]

 

log local0. "Access via [HTTP::version]"

 

}

 

 

switch -glob [string tolower [HTTP::path]] {

 

"/imageserver/plumtree/common/*" -

 

"/imageserver/plumtree/portal/private/*" -

 

"/imageserver/plumtree/portal/public/*" {

 

set cachetime $::twoweeks

 

}

 

"/imageserver/plumtree/portal/custom/*" {

 

set cachetime $::workday

 

}

 

"/imageserver/plumtree/portal/*" -

 

"/documents/*" {

 

set cachetime $::day

 

}

 

"/portal/server.pt/gateway/*.gif" -

 

"/portal/server.pt/gateway/*.css" -

 

"/portal/server.pt/gateway/*.js" -

 

"/portal/server.pt/gateway/*.jpg" -

 

"/portal/server.pt/gateway/*.png" {

 

set cachetime $::workday

 

}

 

"*.gif" -

 

"*.jpg" -

 

"*.png" {

 

set cachetime $::workday

 

}

 

"*.css" -

 

"*.js" {

 

set cachetime $::workday

 

}

 

default {

 

set cachetime 0

 

}

 

}

 

if {not($cachetime == 0)} {

 

HTTP::header remove "If-None-Match"

 

}

 

 

log local0. "URI is [HTTP::path], Cache time: $cachetime"

 

}

 

 

7 Replies

  • This is the rest of the i-rule that is actually telling the browser to cache stuff. We are removing the Etag because it isn't adding any value over last-modified date and our two IIS servers are returning different Etag values for the same file (because their config's aren't in sync).

     

     

    Internet Explorer doesn't seem to want to cache anything with a Vary header in it. We haven't tried stripping that out yet, not sure if we can since I think it is being added by the HTTP profile because we have caching and compression on. I don't want the Vary header because we are already telling proxies that the content is private so intermediary caches won't cache it.

     

     

     

    when HTTP_RESPONSE priority 900 {

     

    if { (not([HTTP::header exists "Cache-control"])) and (not([HTTP::header exists "Content-Disposition"])) } {

     

    if {not($cachetime == 0)} {

     

    HTTP::header remove "Etag"

     

    HTTP::header remove "X-Powered-By"

     

    HTTP::header insert Cache-Control "private,max-age=$cachetime,post-check=$::postcheck,pre-check=$cachetime,must-revalidate,proxy-revalidate"

     

    HTTP::header replace Expires [clock format [expr ([clock seconds]+$cachetime)] -gmt true -format "%a, %d %b %Y %T %Z"]

     

    } else {

     

    log local0. "Cache time is zero: [HTTP::path]"

     

    }

     

    }

     

    }

     

  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    There's a fascinating post on MSIE 4.x, 5.x, and 6.x behavior with regards to compression, caching, and HTTP headers at http://lists.over.net/pipermail/mod_gzip/2002-December/006826.html (Click here). MSIE 7 is a whole other ball of wax, of course, and I won't claim to know all those corner cases.
  • We have added the following into our iRule:

     

     

    HTTP::header remove "Vary"

     

     

    but it seems to still have the Vary header in the response header of files that the browser is not caching.

     

     

    I tried to disable the "Vary header" in the profile, but the GUI did not allow since we are using both ramcache and compression.

     

     

  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    Ok lets try a bigger hack then. Can you modify your rule to add a 'Vary" User-Agent' header? I wonder if we can trick IE to look the first instance of the header (you never know).

     

     

    If you want to pursue this further you might want to open a case with support. I have a feeling that we might have exhausted what we can do here in the forum.
  • We are still having trouble removing the Vary header via an iRule. I tried deleting it and then reinserting just what I want:

     

     

    Vary: User-Agent

     

     

    However, it doesn't seem to want to alter the header. In the meantime, we have removed compression, which in turn, removes the Vary header and the files are now being cached in IE.

     

     

    Please let us know if there is any other specific syntac I can use in my iRule to kill the Vary header from these large files. Thanks!
  • Posted By mgoche on 02/23/2007 12:30 PM

     

     

    We are still having trouble removing the Vary header via an iRule. I tried deleting it and then reinserting just what I want:

     

     

    Vary: User-Agent

     

     

    However, it doesn't seem to want to alter the header. In the meantime, we have removed compression, which in turn, removes the Vary header and the files are now being cached in IE.

     

     

    Please let us know if there is any other specific syntac I can use in my iRule to kill the Vary header from these large files. Thanks!

     

     

     

    The LTM is inserting the Vary header after the iRule processes the server response. This is why you don't see a change in the Vary header. I'm working on a slightly similar case, but will post here once I find a solution that makes sense for you to use.
  • Atou's avatar
    Atou
    Icon for Nimbostratus rankNimbostratus
    Don't know if this is answered in the meantime but you need also add the removal of the "Vary" header in the event CACHE_RESPONSE.