HTTP Cache Manager – Why I should use it and an example.
JMeter is not a browser, but JMeter provides config elements which helped to mimic the browser behavior and make your tests more realistic. “Cache manager” is used to simulate the browser caching behavior in Jmeter by adding caching functionality to HTTP requests within its scope.
During load testing, we do not consider static resource files (like HTML, CSS, js, images, etc.) and JMeter does not download these static resources until it is explicitly configured to do so. HTTP Cache Manager must be included in your test plan if you have enabled your HTTP sampler to “Retrieve All Embedded Resources”.
HTTP Cache Manager will cache these downloaded resources and will not download again from the server until these are modified.
Cache manager properties
- Clear cache each iteration. As it says, each iteration the cached content is wiped.
- Use Cache-Control/Expires header when processing GET requests: If selected then Cache-Control/Expires value is checked against the current time. If the request is a GET request, and the timestamp is in the future, then the sampler returns immediately, without requesting the URL from the remote server.
- Max Number of elements in cache: By default value is set to 5000 which means cache manager will store 5000 items in the cache. You can increase this value but keep in mind that this will consume memory accordingly, and JMeter may throw “out of memory” exception. You may need to adjust your – Xmx value accordingly in JMeter .bat/.sh file or parameters in the RedLine13 load test.
For JMeter documentation, please refer to
Example Test Plan
Showing performance difference with and without HTTPCacheManager
Test plan includes two thread groups (one include cache manager and other does not). Each thread group is hitting the same URL, but you will see the difference in average response times and data transferred KB/Sec. Also, if you look into the View results tree listener, then you will notice “Response code: 304 and Response message: Not Modified” in Sampler results tab for resources which were using cache manager.