0
votes

I'm having a bit of a strange problem with JMeter that almost seems like a bug. I'm running version 5.1.1 r1855137.

I have a standard HTTP Request Sampler and an HTTP Cache Manager. The HTTP request is set to Follow Redirects. It is also set to Use KeepAlive, and to download all embedded resources with up to 6 parallel downloads. The Cache Manager is set to Clear cache each iteration, and to use Cache-Control/Expires headers. A limit of 5000 elements in the cache is set.

I've create a thread group with a loop controller in it. The HTTP request sampler is inside this thread group and loop. The page in the initial request returns a HTTP/1.1 302 Found. I also notice that in the headers there is Cache-Control: private, s-maxage=0. The first time through the loop, JMeter follows the redirect and downloads all of the resources. Subsequent assertions are fine. The second time through, JMeter only sends the request for the initial page and then does not follow the redirect. Following assertions fail because objects are missing that I'm expecting to find in sub requests.

I know this is a cache issue, because if I remove the Loop Controller in the thread group, and instead make the thread group loop, the problem will go away IF I leave the option to "Clear cache each iteration," checked on the Cache Manager. If I turn this option off, the same problem occurs when the thread group loops.

Does anybody know why JMeter does not follow 302 redirects when the cache manager is active? Is the website not following proper protocol by providing a Cache-Control header of private, s-maxage=0?

1

1 Answers

1
votes

Looking at JMeter source code, JMeter caches 2xx and 304s. And GET requests. See: https://github.com/apache/jmeter/blob/master/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/control/CacheManager.java#L355

So it should not be caching your 302s. Have you tried using Redirect Automatically option to see if that works correctly: