We've been using NGINX as cache layer and recently when load testing it we've stumbled upon an unusual problem: the load test would only get cache miss on all the content.
The traffic flows like this: Client > NLB > NGINX > ELB (stickiness) > Application Layer
After a bit of analysis and troubleshooting, I've come to the conclusion that the reason for this behaviour is the lack of the "AWSELB" stickiness cookie in the requests our load injector is sending. When the cookie isn't set, the AWS ELB will send "set-cookie" with a value for AWSELB and will also include a cache-control: no-cache="set-cookie".
Since it has a "no-cache" directive, NGINX ends up not creating the expected cache entry unless that cookie is sent (later requests after this point will have cache HIT behaviour). Been going through a lot of links/questions and the documentation but I've been unable to find a solution so far. Has anyone gone through this and how have you handled it?
Sample request:
GET /asset/style.1234567.css HTTP/2
Host: mytestserver
User-Agent: curl/7.54.0
Accept: */*
Sample response snippet:
< HTTP/2 200
< server: nginx
< date: Tue, 04 Dec 2018 16:35:50 GMT
< content-type: text/css; charset=UTF-8
< content-length: 572353
< accept-ranges: bytes
< cache-control: public, max-age=3600
< cache-control: no-cache="set-cookie"
< set-cookie: AWSELB=VERYBIGCOOKIEWITHAWSELBDETAILS;PATH=/;MAX-AGE=60
< x-proxy-cache: MISS
Closest post/article I've seen to my problem signature but applies to CloudFront and hasn't got any details on how it was handled: https://forums.aws.amazon.com/thread.jspa?messageID=362272