Retrofit is returning cached response

烈酒焚心 提交于 2019-12-06 16:56:53

In your httpClient interceptor, try adding cache control header:

 .addHeader("Cache-control", "no-cache");

EDIT

Just noticed you are on Retrofit2

original.newBuilder().header("Cache-control", "no-cache");

Alternatively try adding it as an annotation to your API method:

@Headers("Cache-control: no-cache")
Response callApi();

According to Docs.

EDIT 2

Okay I suspect it's because of your if condition, your authRetrofit wouldn't be updated if condition failed. Try removing it

if (authRetrofit == null)

Help this helps.

Use Post request instead, I've faced the same problem, rectified by changing my GET method to post and send one random string as a Field.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!