Forum Discussion
Bypass caching when a cookie matching a pattern is present
We have created an iRule which should disable caching for any request containing a cookie matching a pattern (starting with SESS). It seems like all the rules we have tried have no effect. When caching is enabled for the pool, requests are always cached. Here is the latest rule we have:
when HTTP_REQUEST {
set c_cookies [HTTP::cookie names]
if {[lsearch -regexp $c_cookies "SESS*"]} {
CACHE::disable
}
}
Any ideas on why this wouldn't be working? Also, I'm curious if F5's respect the HTTP Cache-Control max-age header.
Hi!
I think you need to use the CACHE_REQUEST event for this.
In regards to the Cache-Control max-age, you might want to try setting "Ignore headers" in the web acceleration profile to "None".
/Patrik
- IheartF5_45022Nacreous
The CACHE::disable command should work from HTTP_REQUEST to prevent the response being returned from cache, however to make doubly sure, try setting it from HTTP_RESPONSE as well (to ensure your response doesn't get cached). Also add in some debugging statements;-
when CACHE_REQUEST { log local0. "[HTTP::uri]" } when HTTP_REQUEST { set fDisable 0 set c_cookies [HTTP::cookie names] set uri [HTTP::uri] if {[lsearch -regexp $c_cookies "SESS*"]} { set fDisable 1 CACHE::disable } } CACHE_RESPONSE { when CACHE_REQUEST { log local0. "[HTTP::uri]" } } when HTTP_RESPONSE { if {$fDisable} { CACHE::disable } }
Hopefully this helps solve your problem.
- IheartF5_45022Nacreous
Sorry totally forgot to paste correct rule 🙂
when CACHE_REQUEST { log local0. "$uri" } when HTTP_REQUEST { set fDisable 0 set c_cookies [HTTP::cookie names] set uri [HTTP::uri] log local0. "$uri" if {[lsearch -regexp $c_cookies "SESS*"]} { set fDisable 1 CACHE::disable } } when CACHE_RESPONSE { log local0. "$uri" } } when HTTP_RESPONSE { if {$fDisable} { log local0. "$uri" CACHE::disable } }
- CharlieMoad_142Nimbostratus
Thanks for the insight. We will test these settings and come back with results.
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