I'm developing an iOS and Android application in React-Native. It all worked fine until one of my Axios responses on Android gave me old data instead of the most recent server data. On iOS there is no problem at all. It's a simple GET request to an HTTPS endpoint, served by a Java / Spring Boot backend, behind an nginx server.
I'm using Expo SDK 31 (latest), with Axios 0.18 and Redux 4.0.1. Also, I'm using redux-axios-middleware from this repo: https://github.com/svrcekmichal/redux-axios-middleware. Weird thing is that whatever debugging I do, whether it's looking into the network inspector on the device or logging the Axios response via an interceptor, it all gives me indeed this old data on Android. Both on physical device and in emulator. Nowhere an error to be seen. Really stuck on this! Other responses in the app, on Android, using Axios, Redux and this middleware in the exact same way, work perfectly fine.
Here is the reducer, zoomed in on the action giving issues:
import { TaskActionTypes } from '../actions/ActionTypes';
export default function taskReducer(state = {}, action) {
switch (action.type) {
...
case TaskActionTypes.GET_TASK_DETAILS:
return { ...state, loading: true };
case TaskActionTypes.GET_TASK_DETAILS_SUCCESS:
return { ...state, loading: false, task: action.payload.data };
case TaskActionTypes.GET_TASK_DETAILS_FAIL:
return {
...state,
loading: false,
error: "Error while fetching task details"
};
...
}
Here is the action itself:
export function getTaskDetails(task) {
return {
type: TaskActionTypes.GET_TASK_DETAILS,
payload: {
request: {
url: task._links.self.href,
method: "get",
}
}
};
}
Expected to see and seen in all other requests: most recent data. Seen: old, appears to be cached data. But it's a total guess where this happens for me because there is no error information and everything works like a charm on iOS.