Hello,
We use HAProxy 3.0 as a frontend of custom Dolibarr-based ERP (created with PHP).
Recently I tried to activate cache at HAProxy level. I used ACLs to cache only some content types (see my configuration below). The result was really strange. The cache hits were correctly present, but application sometimes switched authenticated users - a session was started by ‘user1’ but some time later the username was switched to ‘user2’ (also active at this moment). The sessions are managed by PHP (cookies). What did I do wrong? How can I improve the configuration to avoid such switching?
My HAProxy configuration is as follows:
cache maincache
total-max-size 512
max-object-size 1048576
max-age 600
process-vary off
frontend www-https
...
http-response set-header X-Cache-Status %[var(txn.cache)]
...
backend dynamic
...
http-response set-var(txn.ctype) res.hdr(content-type)
http-response set-var(txn.cache) str("HIT") if !{ srv_id -m found }
http-response set-var(txn.cache) str("MISS") if { srv_id -m found }
acl is_javascript var(txn.ctype) -m sub -i javascript
acl is_css var(txn.ctype) -m sub -i css
acl is_image var(txn.ctype) -m sub -i image
http-request cache-use maincache
http-response cache-store maincache if is_javascript || is_css || is_image
1 post - 1 participant