1

I'm testing a service that uses Etags. The service also sends a Vary header. I want to test the service using the cache, so I can determine cache performance.

But according to JMeter docs and my own observations, the HTTP Cache Manager won't cache those responses:

http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cache_Manager

Does anyone know of a plugin that would support the vary header?

1

According to :

  1. HTTP Cache Manager Documentation

    Responses with a Vary header will not be cached.

  2. JMeter Source

    /**
     * Save the Last-Modified, Etag, and Expires headers if the result is cacheable.
     * Version for Java implementation.
     * @param conn connection
     * @param res result
     */
    public void saveDetails(URLConnection conn, HTTPSampleResult res){
        if (isCacheable(res) && !hasVaryHeader(conn)){
            String lastModified = conn.getHeaderField(HTTPConstants.LAST_MODIFIED);
            String expires = conn.getHeaderField(HTTPConstants.EXPIRES);
            String etag = conn.getHeaderField(HTTPConstants.ETAG);
            String url = conn.getURL().toString();
            String cacheControl = conn.getHeaderField(HTTPConstants.CACHE_CONTROL);
            String date = conn.getHeaderField(HTTPConstants.DATE);
            setCache(lastModified, cacheControl, expires, etag, url, date);
        }
    }
    
  3. RFC 7231

    To inform cache recipients that they MUST NOT use this response to satisfy a later request unless the later request has the same values for the listed fields as the original request (Section 4.1 of [RFC7234]). In other words, Vary expands the cache key required to match a new request to the stored cache entry.

The behaviour is expected, responses from server with the "Vary" header should not be cached, it is intended to be used on interim proxy servers.

  • Yeah, that's the thing. I'm trying to hit our backend with an eTag as if I'm coming from the interim proxy server. – Mick Sear Oct 9 '16 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.