Disable HTTP Cache on Android React Native - react-native

Is there any way to avoid storing api request and response in http_cache on Android rooted device.
I have already tried 'cache-control' but no luck.

Related

Mapbox GeolocateControl not working on safari on http://localhost:3000

i am currently developing an Ionic/vuejs App and i need to display the position of the user on a map. I am using Mapbox gl js to display a map and i use the GeolocateController of mapbox. On Android it is working fine but on ios/safari its not working and i get this error message:
access to geolocation was blocked over insecure connection to http://localhost:3000
Apparently the GeolocateController uses the Geolocation API of JavaScript under the hood and safari doesn't allow to locate the user on an unsecure connection. But when developing, i'm on http://localhost:3000 and even when i build the app and deploy on devices, it's still using http://localhost.
Am i missing something important? Or how can i solve this issue?
When i use the Capacitor Plugin Geolocation, i receive the correct data. Is it somehow possible to "overwrite" the GeolocateController of Mapbox to instead use Capacitor Geolocation when trying to locate the user?
"#ionic/vue": "^5.4.0"
"vue": "^3.0.0-0",

Network call from native module instead from Javascript/React Native

I want to know how to make a network request on app initialization from the native modules instead of doing it in Javacsript/React Native code.
I saw in a video that one way to speed up the initialization time is to move the network requests to the native-modules (iOS/Android), that way when the app is ready the response of the network request is given to React-Native to handle it.
The video is titled "Performance in React Native" by Ram Narasimhan. There is no example provided.
Here's an example I made for both iOS and Android: https://github.com/corinaferencz/network-native-module
Network requests are handled in native, and the response is sent to React Native.

disable http/2 requests in old react-native 0.38.1

We have upgraded our Nginx server and some requests from a mobile app build with react native 0.38.1 http requests stoped working. If we disable http/2 on nginx the requests works again. The problem is noticed only on android phones.
Is there a way to disable react native http2 calls?
We use RNFetchBlob.fetch(.... ) to execute http calls
the error we receive is
Error: Expected ':status' header not present

Impossible to use proxy

I'm trying to use proxy with my react-native app (build with CRNA and Expo).
So in my package.json file I put : "proxy": "192.168.1.27:8080" and then make simple get request with fetch with the/users` path and react call me network error (he don't see the proxy param, just /users when I'm debugging).
The fetch request work well if I put the full url.
In react (for website) I do the same thing and that's work to.
Thank's for your help.
In Reactjs proxies are mainly used to avoid cors issues. Since React Native connects to iOS & Android natively, there is no browser issue so you don't need a proxy.
The approach I use is to call http:127.0.0.1:nnnn/api/route (not localhost) in the React Native app when testing the backend, and the deployed url in production. So you can deploy your server separately and reach it directly in the app.

How to keep http connection alive for React Native's fetch method

I am trying to use RN's fetch() method with http connection alive.
I tried with header 'Connection: keep-alive' but it does not seem to work. I cannot use http.Agent because http module is not supported in React Native. I searched but cannot find an alternative module.(XmlHttpRequest does not work also)
Question: What can I do to keep http connection alive in React Native's environment?
My ultimate purpose is to authenticate a NTLM server in React Native's JavaScriptCore, the authentication needs keep-alive http connection. Any other suggestion is also appreciated.
On Android (and presumably similarly on iOS), the OkHttp client used by ReactNative will by default keep either a Http/1.1 or Http/2 connection alive and reuse it. You should check whether the server is closing the response.
https://en.wikipedia.org/wiki/HTTP_persistent_connection#HTTP_1.1
We created the native module in android/ios to open network connection in JAVA and Objective C and emit events on response.