title: How to do cache clear in Retrofit POST requests
body: <p>How to do cache clear in every 5 minutes and in 24 hours cache expires completely in retrofit API call. In java, network parse response used in the volley request. In kotlin, what should i use for it.
  In java, the following method is used to clear cache entries:</p>
  <pre><code>      protected Response&lt;String&gt; parseNetworkResponse(NetworkResponse response) {
          try {
              Log.e(TAG, &quot;PeopleNearby  parseNetworkResponse&quot; );
              Cache.Entry cacheEntry = HttpHeaderParser.parseCacheHeaders(response);
              if (cacheEntry == null) {
                  cacheEntry = new Cache.Entry();
              }
              final long cacheHitButRefreshed = 5 * 60 * 1000; // in 5 minutes cache will be hit, but also refreshed on background
              final long cacheExpired = 24 * 60 * 60 * 1000; // in 24 hours this cache entry expires completely
              long now = System.currentTimeMillis();
              final long softExpire = now + cacheHitButRefreshed;
              final long ttl = now + cacheExpired;
              cacheEntry.data = response.data;
              cacheEntry.softTtl = softExpire;
              cacheEntry.ttl = ttl;
              String headerValue;
              headerValue = response.headers.get(&quot;Date&quot;);
              if (headerValue != null) {
                  cacheEntry.serverDate = HttpHeaderParser.parseDateAsEpoch(headerValue);
              }
              headerValue = response.headers.get(&quot;Last-Modified&quot;);
              if (headerValue != null) {
                  cacheEntry.lastModified = HttpHeaderParser.parseDateAsEpoch(headerValue);
              }
              cacheEntry.responseHeaders = response.headers;
              final String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
              return Response.success(jsonString, cacheEntry);
          } catch (UnsupportedEncodingException e) {
              return Response.error(new ParseError(e));
          }
      }
  </code></pre>