For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Hendel's avatar
Hendel
Icon for Nimbostratus rankNimbostratus
Jan 31, 2023

Insert header when item added to ramcache

Haven't been in here for a looong time... :-7

Trying to store a header value received from pool member in a new header as that item is added to the ramcache (so it'll be present when that item is subsequently retrieved from the ramcache), but using CACHE::header insert NewHeader $value in the CACHE_UPDATE event doesn't seem to work (13.1) - has anyone used it successfully? 

9 Replies

  • Hey Hendel  - welcome back! I see nobody has come to answer this yet, so I'll see if one of my colleagues can come in to help. 

  • Hendel's avatar
    Hendel
    Icon for Nimbostratus rankNimbostratus

    Thanks, I'd appreciate that - seems like this ought to be pretty simple, so I'm probably just holding the wrong end of the metaphorical wrench or something

     

  • Hi Hendel, I haven't done much with the cache in iRules, but your format for setting appears to be correct. That said, can you post a sanitized version of your iRule and whether you have any other iRules or policies that might be interfering? How are you validating that it is not working? Could use CACHE::trace to see if anything is at least being set by the system before hitting a tcpdump on the wire.

    • Hendel's avatar
      Hendel
      Icon for Nimbostratus rankNimbostratus

      There aren't any other rules or policies. I'd tried both insert and replace, but the logging in CACHE_RESPONSE never showed any effect from either of the UPDATE commands.

      when CACHE_UPDATE {
        CACHE::header insert X-LTM-Cached $cache
        # CACHE::header replace Cache-Control $cache
      }
      when CACHE_RESPONSE {
        log local0. "[IP::client_addr] path:$path cache:$cache [CACHE::headers]"
      }
      when HTTP_REQUEST {
        set path [string tolower [HTTP::path]]
        if { !($path ends_with ".js") } {
          CACHE::disable
        } else {
            HTTP::uri [HTTP::path]
            CACHE::enable
        }
      }
      when HTTP_RESPONSE {
        set cache [HTTP::header value Cache-Control]
        HTTP::header replace Cache-Control public
      }
      • JRahm's avatar
        JRahm
        Icon for Admin rankAdmin

        I updated the formatting to make it a little easier to read through...let me reach out internally to see if anyone has worked with the cache commands before, I'm not quite sure what the flow should be here.

    • Hendel's avatar
      Hendel
      Icon for Nimbostratus rankNimbostratus

      I'm able to log CACHE::headers when I retrieve objects from the cache, it's just that they only come out with all of their original headers/values as sent by the pool member, not the ones I was trying to insert and/or modify as they went in to the cache.

      • John_Alam's avatar
        John_Alam
        Icon for Employee rankEmployee

        i used this version and was able to change the headers Cache-Control.  I was also able to insert headers.  No dynamic values though.

         

        when CACHE_UPDATE {
            CACHE::header insert X-LTM-Cached "test"
            CACHE::header replace Cache-Control "private"
            log local0. "Cache update- path:$path cache: [CACHE::headers]"
        }

         

        But you have to invalidate the cache before every expected change of behavior.  You do that from the CLI with this command:  

         

        tmsh delete /ltm profile ramcache optimized-caching

         

         and reload page twice.  First reload will not have the cached version.

        HTH