# Persist connection based on HTTP::header value

**URL:** <https://community.f5.com/t/persist-connection-based-on-http-header-value/594>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery, ltm\
**Created:** [August 27, 2015, 7:52am UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594 "2015-08-27T07:52:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ariel\_Moreno\_10](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@Ariel\_Moreno\_10](https://community.f5.com/u/Ariel_Moreno_10)\
**Post date:** [August 27, 2015, 7:52am UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594/1 "2015-08-27T07:52:30Z")

</div>

Hello E’all I need an irule to persist a connection to the same pool member based on the value of an HTTP::header I took a look on devcentral and adapted to following irule to my need.

when HTTP\_REQUEST { set Cardtoken [HTTP::header “X-Cardtoken-Id”] if { $Cardtoken eq “” } { log local0. “[IP::client\_addr]:[TCP::client\_port] [HTTP::uri] NO Cardtoken header” } else { persist uie $Cardtoken 60 log local0. “[IP::client\_addr]:[TCP::client\_port]:[HTTP::uri] Cardtoken: [HTTP::header value “X-Cardtoken-Id”], persist record: [persist lookup uie $Cardtoken]” } }

Taking a look to ltm log

Aug 27 03:23:17 DC4-LTM02 info tmm[27804]: Rule /Common/header\_persist\_hash2 : 10.32.174.166:54943:/xxx/cacheFetch Cardtoken: ff8080814f6dd9e3014f6e0a120300c2, persist record: Aug 27 03:23:22 DC4-LTM02 info tmm5[27805]: Rule /Common/header\_persist\_hash2 : 10.32.170.23:15422:/xxx/authorization Cardtoken: ff8080814f6dd9e3014f6e0a120300c2, persist record: /Common/dmz\_807-pool 10.100.107.36 8443

There are some logs with persist records and other without it. I guess it is because it was the first connection, am I right? Any feedback would be really appreciate. Regards

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [August 27, 2015, 1:13pm UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594/2 "2015-08-27T13:13:45Z")

</div>

Is the X-Cardtoken-Id header in **every** HTTP request?

---

<div class="post-metadata">

**Author:** ![Ariel\_Moreno\_10](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@Ariel\_Moreno\_10](https://community.f5.com/u/Ariel_Moreno_10)\
**Post date:** [August 27, 2015, 1:16pm UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594/3 "2015-08-27T13:16:35Z")

</div>

Yes Sir, my application adds it to the each request. Regards

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [August 27, 2015, 2:08pm UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594/4 "2015-08-27T14:08:12Z")

</div>

that assumption would be correct then. The first request isn’t going to have a persistence record because you haven’t created one yet. I’m assuming every subsequent request has a persistence record?

---

<div class="post-metadata">

**Author:** ![Ariel\_Moreno\_10](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@Ariel\_Moreno\_10](https://community.f5.com/u/Ariel_Moreno_10)\
**Post date:** [August 27, 2015, 4:02pm UTC](https://community.f5.com/t/persist-connection-based-on-http-header-value/594/5 "2015-08-27T16:02:29Z")

</div>

Thank you Kevin for your feedback
