jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1358746 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java xdocs/changes.xml xdocs/usermanual/component_reference.xml
Date Sun, 08 Jul 2012 14:35:46 GMT
On 8 July 2012 15:23,  <pmouawad@apache.org> wrote:
> Author: pmouawad
> Date: Sun Jul  8 14:23:54 2012
> New Revision: 1358746
>
> URL: http://svn.apache.org/viewvc?rev=1358746&view=rev
> Log:
> Bug 53522 - Cache Manager should not store at all response with header "no-cache" and
store other types of Cache-Control having max-age value
> Bugzilla Id: 53522
>
> Modified:
>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>     jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
>     jmeter/trunk/xdocs/changes.xml
>     jmeter/trunk/xdocs/usermanual/component_reference.xml
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1358746&r1=1358745&r2=1358746&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
(original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
Sun Jul  8 14:23:54 2012
> @@ -160,13 +160,17 @@ public class CacheManager extends Config
>          Date expiresDate = null; // i.e. not using Expires
>          if (useExpires) {// Check that we are processing Expires/CacheControl
>              final String MAX_AGE = "max-age=";
> -            // TODO - check for other CacheControl attributes?
> -            if (cacheControl != null && (cacheControl.contains("public") ||
cacheControl.contains("private")) && cacheControl.contains(MAX_AGE)) {
> -                long maxAgeInSecs = Long.parseLong(
> -                        cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length())
> -                            .split("[, ]")[0] // Bug 51932 - allow for optional trailing
attributes
> -                        );
> -                expiresDate=new Date(System.currentTimeMillis()+maxAgeInSecs*1000);
> +            if(cacheControl != null) {
> +                if(cacheControl.contains("no-cache")) {
> +                    return;
> +                }

Surely the check for no-cache should be done regardless of whether
useExpires is true?

useExpires should only be used to decide whether to use max-age or not.

> +                if(cacheControl.contains(MAX_AGE)) {
> +                    long maxAgeInSecs = Long.parseLong(
> +                            cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length())
> +                                .split("[, ]")[0] // Bug 51932 - allow for optional
trailing attributes
> +                            );
> +                    expiresDate=new Date(System.currentTimeMillis()+maxAgeInSecs*1000);
> +                }
>              } else if (expires != null) {
>                  try {
>                      expiresDate = DateUtil.parseDate(expires);
>
> Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java?rev=1358746&r1=1358745&r2=1358746&view=diff
> ==============================================================================
> --- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
(original)
> +++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
Sun Jul  8 14:23:54 2012
> @@ -258,7 +258,7 @@ public class TestCacheManager extends JM
>          assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
>          ((HttpMethodStub)httpMethod).cacheControl="no-cache";
>          this.cacheManager.saveDetails(httpMethod, sampleResultOK);
> -        assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
> +        assertNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
>          assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
>      }
>
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1358746&r1=1358745&r2=1358746&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Sun Jul  8 14:23:54 2012
> @@ -70,6 +70,7 @@ in ScriptEngine context, see <bugzilla>5
>  <h3>HTTP Samplers and Proxy</h3>
>  <ul>
>  <li><bugzilla>53521</bugzilla> - Cache Manager should cache content
with Cache-control=private</li>
> +<li><bugzilla>53522</bugzilla> - Cache Manager should not store at
all response with header "no-cache" and store other types of Cache-Control having max-age
value</li>
>  </ul>
>
>  <h3>Other Samplers</h3>
>
> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1358746&r1=1358745&r2=1358746&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Jul  8 14:23:54 2012
> @@ -3217,7 +3217,8 @@ and if so, the If-Last-Modified and If-N
>  Additionally, if the "Use Cache-Control/Expires header" option is selected, then the
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. This is intended to emulate browser
behaviour.
> -Note that the Cache-Control header must be "public" and only the "max-age" expiry option
is processed.
> +Note that if Cache-Control header is "no-cache", response will not be stored in cache,
if Cache-Control has any other value,
> +only the "max-age" expiry option is processed to compute entry lifetime.
>  </p>
>  <p>
>  By default, Cache Manager will store up to 5000 items in cache using LRU algorithm.
Use property to modify this value.
>
>

Mime
View raw message