Bug 59962 - Cache Manager does not update expires date when response code is 304.
Summary: Cache Manager does not update expires date when response code is 304.
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 3.0
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-09 15:27 UTC by Kimono
Modified: 2016-09-03 22:15 UTC (History)
1 user (show)



Attachments
jmx for reproduction (13.60 KB, application/xml)
2016-08-09 15:27 UTC, Kimono
Details
rsult xml file (3.59 KB, application/xml)
2016-08-16 08:03 UTC, Kimono
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kimono 2016-08-09 15:27:33 UTC
Created attachment 34118 [details]
jmx for reproduction

Cache Manager does not update expires date when response code is 304.

If server sends new Expires header with 304, JMeter should not send this request until expired when "Use Cache-Control/Expires header" option is checked.

This is because cacheable response code is limited to 2xx range in isCacheable method(CacheManager.java).

To reproduce with Apache HTTP Server 2.4:
Add settings below to httpd.conf and run attached jmx.
----
LoadModule expires_module modules/mod_expires.so
<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
</IfModule>
----

Expected result:
3rd request of attached jmx should not be sent.
Comment 1 Philippe Mouawad 2016-08-11 19:30:05 UTC
Hello,
Thanks for report.
Could you set Filename in your View Results Tree and save all fields to XML format, run your test and send the output ?

An alternative would be to write a Test method in TestCacheManagerBase.

I am not sure to understand.

1/ First request is sent, and says to cache access + 5 seconds
2/ Your timer runs for 6 seconds, so second request should get a 200, not a 304 
3/ And yes the 3rd request should come from cache. So I don't understand your note on "This is because cacheable response code is limited to 2xx range in isCacheable method(CacheManager.java)."


Thanks
Comment 2 Kimono 2016-08-16 08:03:55 UTC
Created attachment 34155 [details]
rsult xml file

Thanks for your reply.

Detail of expected result is below.

1.1st request is sent, and server returns 200 response with expires date "access plus 5 seconds".
2.After 6 seconds(timer), 2nd request is sent, and server returns 304 response with new expires date "access plus 5 seconds".
3.After 3 seconds(timer), 3rd request should not be sent because cache is not expired.
Comment 3 Kimono 2016-08-22 12:46:17 UTC
I wrote a simple test method for TestCacheManagerBase.

----
    @Test
    public void testExpiresBug59962() throws Exception {
        this.cacheManager.setUseExpires(true);
        this.cacheManager.testIterationStart(null);
        assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
        assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
        long start = System.currentTimeMillis();
        setExpires(makeDate(new Date(start + 2000)));
        cacheResultWithGivenCode("304");
        assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
        assertTrue("Should find valid entry", this.cacheManager.inCache(url));
        sleepTill(start + 2010);
        assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
        assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
    }
----
Comment 4 Philippe Mouawad 2016-09-03 22:15:58 UTC
Author: pmouawad
Date: Sat Sep  3 22:15:03 2016
New Revision: 1759137

URL: http://svn.apache.org/viewvc?rev=1759137&view=rev
Log:
Bug 59962 - Cache Manager does not update expires date when response code is 304.
Bugzilla Id: 59962

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java
    jmeter/trunk/xdocs/changes.xml