Clearing the JMeter cache is usually a matter of configuring the HTTP Cache Manager in your test plan. JMeter keeps cache information for simulated users so repeated requests can behave more like requests from a web browser. That can make a page load faster on later iterations, but it can also affect response times and make tests inconsistent when you expect every request to fetch fresh content.
For most tests, the simplest solution is to add an HTTP Cache Manager and select Clear cache each iteration. This clears the cache at the start of each iteration for each virtual user. If you need a completely fresh cache for a single run, stop the test and start a new run. The right choice depends on whether you are testing a cold cache, a warm cache, or normal repeat browsing.
What Does the JMeter Cache Do?
JMeter’s HTTP Cache Manager simulates parts of a browser’s HTTP caching behavior. It keeps cache-related information for requests made by a virtual user and can use response headers such as Cache-Control, Expires, ETag, and Last-Modified to determine whether content can be reused or needs to be requested again.
This matters most when a thread sends the same request more than once. Depending on the response headers and Cache Manager settings, a later request may be handled as a cache hit or may include conditional headers asking the server whether the content has changed. That can produce a different response time and network workload from a first-time request.
JMeter’s HTTP cache is not the same as a browser cache stored on your computer. It also does not automatically clear a server-side cache, reverse proxy, or content delivery network cache. Before changing your test, identify which cache you mean: JMeter’s per-user HTTP cache, browser cache, cookies, or an application or infrastructure cache.
Clear the Cache at Every Iteration
To make each iteration begin with a fresh JMeter HTTP cache, add an HTTP Cache Manager to your test plan and enable its iteration-clearing option. This is useful when a thread group loops through the same set of requests and each loop should represent a new visit rather than a returning visitor.
- Open the test plan in the JMeter GUI.
- Right-click the relevant test plan, thread group, or controller.
- Select Add, then Config Element, then HTTP Cache Manager.
- Select the HTTP Cache Manager in the tree.
- Enable Clear cache each iteration.
- Save the test plan and run it again.
In normal use, the setting clears cache information at the beginning of each iteration for each thread. A thread’s next pass through the loop can therefore behave like a new cache session. The setting does not clear the cache after every individual sampler. If you need each request to be treated as a first visit, review whether iteration-based behavior is appropriate for your test design.
Place the HTTP Cache Manager where it applies to the requests you want to test. A manager under a thread group is a practical choice when those requests should share the same configuration. If different thread groups need different cache behavior, configure each group accordingly. Remember that JMeter simulates separate virtual users: one thread’s cache is not generally a shared cache for every other thread.
Start a Test with a Fresh Cache
If you want a fresh cache at the beginning of a test run, stop any running test and start a new run. JMeter’s HTTP Cache Manager maintains cache state for virtual users during test execution; it is not normally a persistent browser-cache directory that you need to find and delete between runs. Starting a new run is therefore a straightforward way to test first-visit behavior.
For a reliable cold-cache test, also check the structure of your test plan. Make sure the HTTP Cache Manager is enabled for the requests under test, and verify that threads are not continuing from an earlier loop or reusing a state you intended to reset. If you are running JMeter in non-GUI or distributed mode, start a new test execution on the relevant load generators as well.
A new JMeter run does not guarantee that every layer in your application stack is cold. A web server, proxy, CDN, database, or application may have its own cache that remains warm. If response times still look like cached responses, inspect server-side behavior and response headers rather than assuming JMeter retained the data.
Disable JMeter Caching for a Test
If your goal is to prevent JMeter from simulating browser caching, disable or remove the HTTP Cache Manager that applies to the requests. Without the manager, JMeter will not use its HTTP Cache Manager behavior to keep and reuse cache entries. This can help isolate a test, but it is not always equivalent to clearing a browser cache and then using a browser normally.
Use this approach when you specifically want to measure requests without JMeter’s cache handling. Keep it separate from a realistic browser-cache test: disabling the manager changes the simulated behavior, while clearing the cache allows the manager to operate with no entries at the start of an iteration.
Before removing the manager from a large test plan, check whether other samplers depend on it. A manager attached at a broader level may apply to multiple thread groups or controllers. Save a copy of the test plan if you want to compare cached and uncached results without losing the original configuration.
Check the HTTP Cache Manager Settings
The HTTP Cache Manager includes settings that affect how JMeter handles cached content. Review these options when clearing the cache does not produce the request pattern you expect. Exact labels or available options can vary between JMeter versions, so use the settings shown in your installed version.
- Clear cache each iteration: Clears the cache at the start of an iteration for each thread.
- Use Cache-Control/Expires header: Uses response caching headers when deciding how cached responses should be handled.
- Max Number of elements in cache: Limits how many entries the manager retains.
- Implementation and related options: Depending on the JMeter version, additional settings can influence how the manager processes cached responses.
Do not assume that every response will be stored simply because the manager is present. The server’s response headers, the type of request, and the manager’s configuration all influence caching. To confirm what is happening, compare request and response headers in JMeter’s results or view the request details in a listener such as View Results Tree during debugging. Avoid keeping resource-heavy listeners enabled during large load tests.
Clear the Cache for Embedded Resources
A page may load additional resources such as images, stylesheets, and scripts. In JMeter, the HTTP Request sampler can be configured to retrieve embedded resources from HTML responses. If your test includes those requests, the HTTP Cache Manager can affect repeated resource requests as well as the main page request.
Check the sampler’s embedded-resource settings and the response headers for the resources you are testing. A page request may be fresh while some assets are treated as reusable, or the reverse, depending on their caching rules. If your goal is to test the full first-page experience, include the relevant embedded resources and clear the cache at the start of each iteration.
Be cautious when comparing JMeter with a browser’s developer tools. Browsers can apply additional policies and maintain disk or memory caches differently. JMeter is a performance-testing tool that models HTTP behavior; it is not a complete browser engine.
JMeter Cache, Cookies, and Server Cache Are Different
Clearing the HTTP cache does not necessarily reset other user or application state. Cookies, authentication tokens, server-side sessions, and application data can change what a virtual user receives. If a test needs a new user session each iteration, configure cookie handling separately from cache handling.
- HTTP Cache Manager: Handles HTTP caching behavior for virtual users.
- HTTP Cookie Manager: Stores and sends cookies, which can preserve a user session.
- Browser cache: Belongs to a real browser profile and is separate from JMeter’s cache manager.
- Server, proxy, or CDN cache: Exists outside the JMeter process and may need to be cleared or bypassed through the system being tested.
If users appear to stay logged in after you clear the JMeter cache, inspect the HTTP Cookie Manager and session behavior. If content remains fast or unchanged, inspect cache-related response headers and the server or CDN configuration. Clearing one type of cache does not automatically clear the others.
Troubleshooting When the Cache Still Seems Active
Start by confirming that the HTTP Cache Manager is attached to the correct part of the test plan and that Clear cache each iteration is selected. Then check that the thread group has more than one iteration; if it runs only once, iteration-based clearing may not produce a visible difference between loops.
Next, inspect the actual requests and responses. Look for conditional request headers such as If-None-Match and If-Modified-Since, and response headers such as Cache-Control, Expires, ETag, and Last-Modified. A 304 Not Modified response indicates that the server confirmed the stored representation is still valid. This is not necessarily an error; it may be the intended caching behavior.
Also verify whether you are comparing equivalent runs. The number of threads, ramp-up, loop count, embedded-resource settings, cookies, and server-side cache state can all affect results. Change one factor at a time and run a small test so you can identify what changed.
Which Cache-Clearing Method Should You Use?
Choose the method that matches the scenario you want to measure. For a cold-cache experience on every pass, enable Clear cache each iteration. For a fresh initial state followed by realistic reuse during the run, start a new test execution and leave per-iteration clearing disabled. To exclude JMeter’s cache handling altogether, disable or remove the HTTP Cache Manager. To reset cookies or application state, configure those separately.
Document the chosen behavior in your test plan so results are easy to interpret. A test with a fresh cache on every iteration measures a different workload from one where virtual users revisit cached resources. Keeping that distinction clear helps you avoid misleading response-time comparisons.
Conclusion
To clear the JMeter cache between repeated test iterations, add an HTTP Cache Manager and select Clear cache each iteration. To begin with a fresh cache, stop and start a new test run. If you want to prevent JMeter cache handling entirely, disable or remove the manager. Finally, remember that cookies, browser storage, and server-side caches are separate: clear or configure each one according to the behavior your performance test is meant to simulate.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.