Bug 59962

Summary: Cache Manager does not update expires date when response code is 304.
Product: JMeter - Now in Github Reporter: Kimono <kimono.outfit.am>
Component: HTTPAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2    
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: jmx for reproduction
rsult xml file

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
Comment 5 The ASF infrastructure team 2022-09-24 20:38:05 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4049