File from URL not updated

Hello,
I have a problem with the update of a file. In my app i download a txt file from a server. It is working, i can extract the text from the file and i can display the text in a label. I use a clock to download the file every 1 sec. But when i change the txt in the file from the server, the txt in my app are not updated. I have always the old txt displayed in the label. It is like the app use a cache or something like this. After something like 1h (i didn't check exactly the timer), t he new data are displayed.
I tried to remove the file to clean the file and have "fresh" data every clock loop, but it is not working.

Capture d’écran 2021-10-24 024421

Do you have an idea how to force the app to update the data?
Thanks ,Nico

1 Like

Are you using this block?

component_set_get
It will direct your response that you got from your server.
If it TRUE, GotFile event will be triggered.
Otherwise, GotText will be triggered.
Hope that help.

1 Like

thanks @momoney, I update the code with your clarification but it is not better. i changed saveResponse to false and use directly gotText. I can see the text from my file in the label2, up to there it is ok. But if i change the text in the file on the server, the text in the label 2 don't change, the label 2 display always the original text. Like if we use a cache or something lie this. I tried to reset the app but no change.

(the random is just to be sure that i use the gotText)

I also tried with saveResponse to yes and use gotfile (second sceenshot) but it is same result. It is realy like the "call web1" don't refresh the file anyway if the response code is 200.

This is with saveresponse to yes

1 Like

How about while waiting for one second to lapse, try to visit "random" site (ex: https://google.com) before you try to fetch the data from your server again?

Hi, in the clock loop i added 1/a visit to google.com and 2/ the visit to my txt file.
On the label 4 i have "rotation" of the 2 visits. Google page in txt format and my txt file. But anyway it doesn't take account the change in the txt file. It is like for the first visit, it download the file but after it doesn't download anymore and use cache file somewhere.

hi @TIMAI2, actually the download work because i can see the content of my txt file. But when i want download again the same file after i changed the txt inside the file, it doesn't download the file. I always see the original content event if the result code is 200. It is like the app use a file from a cache/buffer or something like this to reduce data transfer.

Even refresh the companion don't help.

If i call the txt file from a browser I can see the new txt.

Thanks
Nicolas

This is working for me

image

@TIMAI2 Yes, but if you change the content of the data.txt on your server can you see "immediately" this change in your label1?

This is my point, the change in content of text file is only passed on the app after long delay (1/2h or 1h) even if the clock is doing the request "web1.get" every second.

Thanks

Yes I see the change as soon as I change the file data and save the file

OK, so it is something strange on my side. If i call the txt file in the browser i can see the change, i have a php page also calling this txt file and i can also see immediately the change. It is only with the MIT app that i cannot see the update. I don't understand.

I tested again on my smartphone and on the emulator. i have indeed a "refresh" every 1h exactly.

I created a new project to keep it simple. I just display the content of the txt file. On the screenshot you see that the file below/right in a browser, there is one extra line compared to the emulator top/right. After one Hour that the text file was updated, the label1 on emulator is aligned with the file.

I don't know if it should be something from the server config. i don't see where else it could come from.I should find an other server to test it.

Certainly sounds like a server setting....

Hi,
Just to give the conclusion, it was indeed a problem of cache on the server side. :unamused: I have to add a htaccess file in my server directory to disable the cache.
Thank for your help.

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