clear Http cache in Expo Reactive Native

#1

I am trying to use webview to display a website in my expo react native app, I set a URL to html page in webview. Worked fine. But when I updated and deployed, the updated content is not shown in WebView in react native Android app. When I directly to that URL using a browser I see the HTML is updated. Looks it is cache somewhere in the mobile.

i tried react-native-http-cache but i am not to link in expo as i don’t have access to gradle files. is there other solution?

0 Likes

#2

Hey @sagarv1997 - thanks for the report. I think you’re right, the old data is being stored in a cache somewhere you don’t want it. Would you be willing to share the URL you’re trying to display in the WebView, or if not, the Cache-Control headers that are sent in the response?

Also, it would be interesting to see if you can do anything that makes the WebView get the correct code – e.g. does restarting the app/phone/waiting 24h make any difference?

0 Likes

#3

I am trying on this page

And on deleting the app storage file new content from the website is loaded

0 Likes

#4

Hi! Thanks for the link. It looks like your website is currently telling browsers (including webview) that they can safely cache the contents for up to an hour:

I would recommend tracking down where that’s configured and trying to change it, seeing if that affects the loading behavior of your webview.

0 Likes

#5

Checked for more than an hour but still it wasn’t changing, for now i have added a random string at end of the url, so it will every time load as a page

0 Likes

#6

Why not set the cache-control header in your fetch request (fetch accepts a second parameter, an object, which contains a child object called headers) in your app to bypass the cache without loading your url?

0 Likes

closed #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

0 Likes