0

I am trying to fetch an uncached version of this url: https://github.com/vedantroy/image-test/raw/master/version.txt or this url: https://raw.githubusercontent.com/vedantroy/image-test/master/version.txt in Android.

I thought I solved the problem in this post: Fuel Android - Make non-cached request , but I'm still getting cached versions of those two URLs.

How can I fetch uncached versions of the file at those two URLs?

I'm open to using any Java or Kotlin library.

Foobar
  • 7,458
  • 16
  • 81
  • 161

1 Answers1

0

You are probably getting the content from cache because of the header of your last API call. You can change the Control-Cache header to control wheter you want to cache it or not.

For example with retrofit:

@GET("ws/exampleUrl")
Something getSomething(@Header("Cache-Control") String cacheControl);

and set the Cache-Control header to no-cache If you don't want to hold it:

myApi.getSomething(forceRefresh ? "no-cache" : null);
Adib Faramarzi
  • 3,798
  • 3
  • 29
  • 44