Jmeter provides many features to make your performance tests more realistic.Though Jmeter is not a web browser, it provides config elements to replicate the actual browser behavior. One such config element and one of the most important Jmeter feature is HTTP Cache Manager. In this article we are going to discuss about what is HTTP Cache Manager why it is required. First, we need to understand the fundamentals of Web Browser Caching.

What is a Browser Cache?

The concept of Browser caching emerged from this question, Why download the same data for every web page? Why not just download it once and store to use it again? The browser Cache is a temporary storage location of the files downloaded by your web browser do display the website. Cache includes html files, CSS style sheets, JavaScript scripts and other multi-media files.

When you visit a web page first time, browser downloads all these files into the cache. Next time when you are revisiting the page, browser checks for the updated content and only downloads those files which are not stored on cache. This mechanism reduces the bandwidth usage and it helps to load the web page faster.


Use of HTTP Cache Manager in Jmeter

Jmeter does not download static content until it is explicitly configured to do so. If you have checked “Retrieve All Embedded Resources” option, Jmeter will download all static files (like HTML, CSS, js, images, etc.) during the execution. And so, its time to include HTTP Cache Manager to achieve browser like caching behavior.

Cache Manager will save all these static files and will not download again from the server until modified. As simple as that!!

Now we will add HTTP Cache Manager and understand it’s attributes.

How to Add HTTP Cache Manager?

1) Open Jmeter and right click on Test Plan.

2) Add > Config Element > HTTP Cache Manager.

HTTP Cache Manager

HTTP Cache Manager Attributes

Clear Cache each Iteration : After each iteration the cached content is cleared.

Use Cache-Control/Expires header when processing GET requests: If this option is selected, Jmeter will check Cache-Control/Expires value against the current time. If the time stamp is in future and the request is a Get request then the Sampler returns immediately, without requesting the URL from the Server.

Maximum Number of Elements in cache:┬áJmeter save all cache resource in RAM. By default, Cache Manager stores up to 5000 items in cache per virtual user. If you increase this value, Jmeter will consume more memory accordingly. It can lead to “OutOfMemory” exception. To avoid such behavior, you should adjust JVM-Xmx option in jmeter.bat\sh.

Use this config element based on you performance testing requirement and make your test run more reliable. Any question??


Share This Article :