Example usage for com.squareup.okhttp CacheControl noCache

List of usage examples for com.squareup.okhttp CacheControl noCache

Introduction

In this page you can find the example usage for com.squareup.okhttp CacheControl noCache.

Prototype

boolean noCache

To view the source code for com.squareup.okhttp CacheControl noCache.

Click Source Link

Usage

From source file:com.kubeiwu.easyandroid.easyhttp.core.retrofit.GsonConverter.java

License:Apache License

private void parseCache(Request request, T object, String string, String mimeType)
        throws UnsupportedEncodingException {
    com.squareup.okhttp.CacheControl cacheControl = request.cacheControl();
    if (cacheControl != null) {
        if (!cacheControl.noCache() && !cacheControl.noStore()) {
            if (object instanceof EAResult) {
                EAResult kResult = (EAResult) object;
                if (kResult != null && kResult.isSuccess()) {
                    long now = System.currentTimeMillis();
                    long maxAge = cacheControl.maxAgeSeconds();
                    long softExpire = now + maxAge * 1000;
                    System.out.println(":" + (softExpire - now) / 1000 + "");
                    Cache.Entry entry = new Cache.Entry();
                    entry.softTtl = softExpire;
                    entry.ttl = entry.softTtl;
                    // entry.serverDate = serverDate;
                    // entry.responseHeaders = headers;
                    entry.mimeType = mimeType;
                    System.out.println("request.cacheControl()==" + request.cacheControl());
                    entry.data = string.getBytes(UTF8);
                    cache.put(request.urlString(), entry);
                }//  w ww .j ava  2 s  .c  om
            }
        }
    }
}

From source file:it.http.HttpHeadersTest.java

License:Open Source License

private static void assertCacheInBrowser(Response httpResponse) {
    CacheControl cacheControl = httpResponse.cacheControl();
    assertThat(cacheControl.mustRevalidate()).isFalse();
    assertThat(cacheControl.noCache()).isFalse();
    assertThat(cacheControl.noStore()).isFalse();
}

From source file:it.http.HttpHeadersTest.java

License:Open Source License

private static void assertNoCacheInBrowser(Response httpResponse) {
    CacheControl cacheControl = httpResponse.cacheControl();
    assertThat(cacheControl.mustRevalidate()).isTrue();
    assertThat(cacheControl.noCache()).isTrue();
    assertThat(cacheControl.noStore()).isTrue();
}