Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit - Different API responses on different devices

The problem exactly like the following I have one api which can provide some data and one apk,

I got my api response with my device and another different old response on the emulator with the same apk!

The emulator response is up to date with the latest changes while the other different response is before the changes.

The app uses retrofit without caching. So what could be the problem?

Request contains only one header (access token) Response contains headers like (ETag, Access-Control-Max-Age) but retrofit should not deal with them as there is no cache at all.

Screen shot from postman : enter image description here

Also when waiting for a while all devices become up to date!

like image 275
Hoby Avatar asked Jan 31 '18 12:01

Hoby


1 Answers

Are you sure with this?

The app uses retrofit without caching

Based on this https://github.com/square/retrofit/issues/678, I think that retrofit (OkHttp inside retrofit) caching your query.

You can change this behavior by 2 ways:

  • add ?_t=TIMESTAMP into your app query url
  • remove 'Access-Control-Max-Age' header from your server response
like image 169
Alex Mamaev Avatar answered Sep 21 '22 14:09

Alex Mamaev