Real browsers do not download unchanged stylesheets and scripts on every page view. The JMeter HTTP Cache Manager gives each virtual user a separate cache, so repeated requests can reuse responses that are still fresh.

The manager affects HTTP samplers within its scope, usually the requests under a Thread Group. Freshness headers allow a repeat GET request to skip the server entirely, while validators such as ETag let JMeter ask whether an expired resource has changed.

An existing HTTP test plan and a cacheable resource are needed to observe reuse. Cached requests normally do not generate extra sample results, which makes a short run easier to inspect than a full load test.

Steps to add a JMeter HTTP Cache Manager:

  1. Select the Thread Group containing the HTTP requests to cache.

    The short test needs one virtual user, one GET sampler for a cacheable resource, and an empty View Results Tree listener. A stylesheet or script served with a positive Cache-Control: max-age is suitable.
    Related: How to create an HTTP test plan in JMeter
    Related: How to debug a JMeter sampler with View Results Tree

  2. Set Loop Count to 2 in the Thread Group.

    Infinite is unchecked and Same user on each iteration remains selected for repeat visits by the same virtual user.

  3. Choose Add → Config Element → HTTP Cache Manager from the Thread Group context menu.
  4. Confirm that the cache manager has its default reuse settings.

    The Clear cache each iteration? and Use Thread Group configuration to control cache clearing checkboxes are unchecked. The Use Cache-Control/Expires header when processing GET requests option is selected. Clearing the cache each iteration would prevent reuse between loops. The default Max Number of elements in cache is 5000 per virtual user; larger limits increase memory use.

  5. Save the test plan with File → Save.
  6. Start the short test with Run → Start.

    The GUI run is for the small cache check. Full load tests belong in non-GUI mode.
    Related: How to run a JMeter test from the command line

  7. Open View Results Tree in the test plan.
  8. Select the result for the cacheable GET request.
  9. Open the Response data tab.
  10. Select Response headers.
  11. Confirm that the two-loop run produced one successful request for the fresh resource.

    The response shown has 200 OK and Cache-Control: max-age=600. With JMeter's default cached-resource result mode, the fresh repeat is skipped and adds no second sample. Two identical 200 results mean the repeat was downloaded again. A 304 response indicates revalidation rather than a skipped request; expired or no-cache responses may need that server check.

Share this guide