In JMeter's HTTP Request, how do Follow Redirects and Redirect Automatically differ?
answer
- Two boxes, never both at once
- One hides the hops, one shows them
- Parent time covers the whole chain
- A property caps the chase at twenty
basics
~20 sFollow Redirects makes JMeter chase the Location itself and record every hop as a sub-sample. Redirect Automatically hands the chase to the HTTP client, so the hops never become samples. The two checkboxes are mutually exclusive.
solid answer
~40 s`Redirect Automatically` (`HTTPSampler.auto_redirects`) lets the underlying implementation follow the chain; JMeter sees only the final response, so no sub-samples appear and the sample's URL is rewritten to where it ended up. The manual limits it to `GET` and `HEAD`. `Follow Redirects` (`HTTPSampler.follow_redirects`) only takes effect when the automatic one is off — the GUI unticks one when you tick the other — and makes JMeter sample each hop and attach it as a sub-sample. On the parent result the URL, response code and body come from the final hop, the elapsed time and byte count cover the whole chain, and the Latency is still that of the *first* response. The chase stops at `httpsampler.max_redirects`, default 20.
go deeper
Recall that the two checkboxes are alternatives, not a pair, and that only one of them puts the intermediate requests into your results.
Explain which fields of the parent sample come from the final hop and which from the first, and name the property that caps the number of redirects followed.
Show what each choice does to a results file people will read later: extra rows and per-hop timings, versus one row whose duration quietly contains hops nobody can see.
Decide the house rule for a suite: whether hops are measured or collapsed, and how you stop a plan where half the samplers follow redirects and half silently stop on a green 302.
Both checkboxes sit on the **Basic** tab of JMeter's HTTP Request sampler, in the option row under the Path field beside *Use KeepAlive* and the multipart switches. Both end up at the same place — the final page. They differ in *who* does the following, and that decides what your results file contains. ## Redirect Automatically `HTTPSampler.auto_redirects` tells the underlying HTTP implementation to chase the `Location` header itself. JMeter is handed only the final response. Consequences: - **No sub-samples.** The hops are invisible; the sample's elapsed time silently includes them. - The result's URL is rewritten to the URL the client ended on, so the sample no longer names the URL you asked for. - The manual restricts it to `GET` and `HEAD`, and warns that cookies are only seen for the last host in the chain while headers you set are sent to the first request only. The state-holding config elements that own those two problems are a separate topic. ## Follow Redirects `HTTPSampler.follow_redirects` has **no effect at all** unless *Redirect Automatically* is off — the manual says so and the GUI enforces it, because ticking either checkbox unticks the other. When it is the active one, JMeter drives the chase itself in `followRedirects()`: 1. it reads the `Location` from the response, collapses any `/segment/..` in it (suppressible with `httpsampler.redirect.removeslashdotdot=false`), and re-encodes spaces as `%20`; 2. it samples that URL and attaches the result as a **sub-sample**; 3. it repeats until a non-redirect arrives, or until `httpsampler.max_redirects` — default `20` — is reached, at which point it attaches an error sub-sample saying the maximum number of redirects was exceeded. ## What the parent sample reports This is the part interviewers push on, because the fields do not all come from the same hop. | Field on the parent | Where it comes from | |---|---| | URL, method, query string, request headers | the **final**, non-redirected response | | Response code, message, body, content type | the **final** response | | Elapsed time and byte count | the **whole chain**, first hop to last | | Latency | the **initial** response only | So a three-hop login flow shows one parent sample whose 200 and body are the landing page, whose time covers all three requests, and whose Latency is the time to first byte of the first `302`. Reading Latency as "time to first byte of what I got back" is wrong here. ## Ticking neither If both boxes are off, JMeter records the `3xx` and stops. JMeter treats every code from 200 to 399 as success, so that sample is **green** — a redirect you did not intend to stop at looks like a pass, and the next sampler in the plan runs against whatever you hard-coded rather than against where the server sent you. ## Choosing between them - Tick **Follow Redirects** when you want the hops in your results: each one is timed, each one is a row in the JTL, and you can see which redirect is slow. - Tick **Redirect Automatically** when the hops are noise and you want one row per logical page — accepting that the intermediate requests still cost the same wall-clock time inside that one number. - Tick neither only when you are deliberately asserting on the redirect response itself.
- With Follow Redirects on, which hop does the parent sample's Latency come from?The first one. JMeter builds the parent by cloning the initial result, then only overwrites the URL, method, query string, request headers, response code, message, body, content type and headers from the final hop. Latency is never re-copied, so it stays the time to first byte of the original request while the elapsed time grows to cover every hop.
- What happens to a 302 if neither redirect checkbox is ticked?JMeter records the 302 itself as the result and goes no further. Because it treats 200-399 as success, that sample is reported as passing, and the following samplers run against whatever URLs you configured rather than the redirect target.
- Why does JMeter sometimes log 'Redirect requested but followRedirects is disabled'?The HttpClient implementation emits it when its own automatic redirect handling is switched off because JMeter is doing the following itself. The manual says explicitly that the message can be ignored; it is not a symptom of a misconfigured sampler.
saying these in an interview costs you the question
- Says both checkboxes can be ticked at the same time
- Thinks Redirect Automatically still records each hop
- Believes JMeter chases redirects without any cap
- Claims the parent's latency covers the whole chain
- Assumes an unfollowed 302 is reported as a failure