From af0eec77f362b6073197cf23ba86686bc5f1eccd Mon Sep 17 00:00:00 2001 From: Nicolas Cornette Date: Wed, 22 Jun 2016 15:39:34 +0200 Subject: [PATCH] Update publish configuration and README.md --- README.md | 35 ++++++++++++++++++++++--------- okcache-control/build.gradle | 6 +++++- okcache-control/gradle.properties | 2 +- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 663105a..593977b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # OkCacheControl -Helper class to configure cache behaviour of OkHttp client, also works with Retrofit for Android. +Helper class to configure cache behaviour of OkHttp client, also works +with Retrofit for Android. ## Usage -Initialize OkCacheControl with `OkHttpClient.Builder()`, then you can call 3 methods : +Initialize `OkCacheControl` with *OkHttpClient.Builder()*, then you can +call 3 methods : - `overrideServerCachePolicy(MaxAgeControl)` - `forceCacheWhenOffline(NetworkMonitor)` @@ -21,15 +23,28 @@ Initialize OkCacheControl with `OkHttpClient.Builder()`, then you can call 3 met ## Description - - `overrideServerCachePolicy(MaxAgeControl)` will override server cache policy with `Cache-Control: max-age` - on responses. Cache will be used until expiration even if network is available. Use it when server doesn't - implement a cache policy. - - `forceCacheWhenOffline(NetworkMonitor)` will force the use of cache when no network connection is available. - When offline, cache will be used even if expired. for `Android` you can implement a `NetworkMonitor` that returns - the value of `ConnectivityManager.getActiveNetworkInfo().isConnected()`. -Call `apply()` to add interceptors to `OkHttpClient.Builder` then it returns the builder so you can continue to build -and add the cache. + - `overrideServerCachePolicy(MaxAgeControl)` will override server cache policy + on responses with *Cache-Control: max-age*. Cache will be used until expiration + even if network is available. Use it when server doesn't implement a cache policy! + + - `forceCacheWhenOffline(NetworkMonitor)` will force the use of cache when + no network connection is available. When offline, cache will be used even + if expired. for Android you can implement a *NetworkMonitor* that returns + the value of *ConnectivityManager.getActiveNetworkInfo().isConnected()*. + +Call `apply()` to add interceptors to *OkHttpClient.Builder* and return the +builder so you can continue to build *OkHttpClient* and add the cache. + +### Per request cache control + +without `Cache-Control` header, cache is used until expiration, then network. +(with `forceCacheWhenOffline()` expired cache will be used when offline) + +- add `Cache-Control: no-cache` to always use network, cache will be used +only when offline. + +- add `Cache-Control: no-store` to not store response in cache. ## Installation diff --git a/okcache-control/build.gradle b/okcache-control/build.gradle index f71bc35..8afbe8d 100644 --- a/okcache-control/build.gradle +++ b/okcache-control/build.gradle @@ -27,14 +27,18 @@ publishing { } bintray { + dryRun = false user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') publications = ['mavenJava'] pkg { - repo = 'generic' + repo = 'maven' name = "${POM_ARTIFACTID}" licenses = ['Apache-2.0'] vcsUrl = 'https://github.com/ncornette/OkCacheControl.git' + version { + name= "${POM_VERSION}" + } } } diff --git a/okcache-control/gradle.properties b/okcache-control/gradle.properties index 0ee0439..74eced2 100644 --- a/okcache-control/gradle.properties +++ b/okcache-control/gradle.properties @@ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -POM_VERSION=1.0.0-SNAPSHOT +POM_VERSION=1.0.0 POM_ARTIFACTID=okcache-control POM_GROUPID=com.ncornette.cache