Bug 64915 - JMeter Cache Manager misbehaving when "Use Cache-Control/Expires header" is checked
Summary: JMeter Cache Manager misbehaving when "Use Cache-Control/Expires header" is c...
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 5.2.1
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: JMETER_5.4
Assignee: JMeter issues mailing list
Keywords: FixedInTrunk
Depends on:
Reported: 2020-11-11 01:08 UTC by Vinod Seraphin
Modified: 2020-11-17 09:53 UTC (History)
0 users

Simple test plan to test the cache manager with different headers in responses (13.13 KB, application/xml)
2020-11-16 12:25 UTC, Felix Schumacher

Note You need to log in before you can comment on or make changes to this bug.
Description Vinod Seraphin 2020-11-11 01:08:39 UTC
Finding that for normal GET requests (REST API transactions) which don't return any of the relevant cache-control/expires (or Last-Modified) headers, Jmeter seems to cache the request and use it on subsequent transactions.

The headers returned with the JSON are:
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Content-Length: 1321
Date: Tue, 10 Nov 2020 22:03:36 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Connection: keep-alive

Both Firefox and Chrome will go ahead and send the GET transaction to the server, but with JMeter the 2nd and subsequent transaction with the same path is not fired (it does pass control to the pre-processor).

This bug does not reproduce with JMeter 3.2 but does with 5.2.1 and 5.3
Comment 1 Felix Schumacher 2020-11-14 12:19:44 UTC
Yes, it seems, that we are a bit too heavy on the caching side and cache all results, that have no explicit caching related header. Will look into this next week.
Comment 2 Felix Schumacher 2020-11-16 12:25:23 UTC
Created attachment 37567 [details]
Simple test plan to test the cache manager with different headers in responses
Comment 3 Felix Schumacher 2020-11-16 12:27:07 UTC
@Vinod, could you test the next nigthly or trunk build (https://jmeter.apache.org/nightly.html) and report back, whether the issue is solved for you?

commit 589511cf254b894353494546b82df6f45a6e1066
AuthorDate: Mon Nov 16 13:22:57 2020 +0100

    JMeter Cache Manager misbehaving when "Use Cache-Control/Expires header" is checked
    Don't store http responses in the cache, if they have no caching related headers.
    Bugzilla Id: 64915
 .../jmeter/protocol/http/control/CacheManager.java | 21 ++++++++++++----
 .../http/control/TestCacheManagerBase.java         | 12 ++++++++++
 .../protocol/http/control/TestCacheManagerHC4.java | 24 ++++++++++++++++---
 .../control/TestCacheManagerUrlConnection.java     |  6 +++++
 .../control/TestCacheManagerUrlConnectionBase.java | 28 +++++++++++++++-------
 xdocs/changes.xml                                  |  1 +
 6 files changed, 76 insertions(+), 16 deletions(-)
Comment 4 Vinod Seraphin 2020-11-16 18:00:22 UTC
Yes, @Felix, happy to test a nightly build.  Thanks for quick attempted fix for this issue.  I see 1911 presently available.  Once 1912 or better is available, I will download and test and update post with what I find.  If 1911 already contains your change and I don't need to wait for 1912, just let me know.
Comment 5 Felix Schumacher 2020-11-16 18:58:10 UTC
The 1912 should the next nightly with the changes. If you want to, you can take the build from trunk https://builds.apache.org/job/JMeter/job/JMeter-trunk/ which should be the same and contains the patch already.
Comment 6 Vinod Seraphin 2020-11-17 06:01:42 UTC
Confirmed that the changes provided in nightly build 1912 fixes this issue.  Thanks!
Comment 7 Felix Schumacher 2020-11-17 09:53:06 UTC
Thanks for reporting, checking and the good description of the problem, that made it easy to replicate the issue.
Comment 8 The ASF infrastructure team 2022-09-24 20:38:21 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5430