Forum Discussion
Insert header when item added to ramcache
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
}Are you using the webacceleration profile: optimized-caching?
can you post any changes you may have made.
Can you include a log statement in the CACHE_UPDATE event so we can see if it is firing?
when CACHE_UPDATE {
log local0. "Caching [HTTP::uri]"
}
Thanks.
- John_AlamFeb 08, 2023
Employee
I did some quick testing.
1) Your iRule does not work as is, the variable 'cache' is not passed from LTM Events to Cache events. So you will run into "variable not found" TCL errors. I excluded that variable to continue testing.
2) I used the 'optimized-caching' profile which defaults to 'Minimum Object Size' of 0 bytes. I could not get the header to insert, or the CACHE_UPDATE to fire, until I increased that to 1 byte. It must be a bug of sorts.
You can see the header inserted X-LTM-Cached: test. Note , i used a static value because as i mentioned, the variable was not transfered.
One way to transfer variable is with iRule tables. Try passing from one event to another using a Table record.
HTH.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com