How do I remove a JSON from browser cache

Get help using Construct 2

Post » Sun Sep 11, 2016 2:52 am

My game loads a JSON data file from the web directory I've uploaded it too. I'm trying to update the JSON file on the fly, but it appears to be cached in the browser so even after I've uploaded the new file, the online game will continue using the old version of the file stored in the browsers memory (unless I refresh several times, or clear the browser cache manually).

I've deleted the JSON file from the offline.appcache file that's created once the game is exported, but it still doesn't seem to work.

Does anyone know how to automatically re-download a JSON file every time (or possibly detect when changes have been made and only re-download it then)? The game depends on this file being up to date.

Thanks in advance.
B
86
S
28
G
10
Posts: 96
Reputation: 10,277

Post » Sun Sep 11, 2016 3:27 am

I'm sure someone can provide a more detailed response but the quick fix might be to use the Browser object to Reload the page at some point after you've modified the JSON data.
B
47
S
18
G
84
Posts: 2,265
Reputation: 49,784

Post » Sun Sep 11, 2016 7:10 am

If you're using ajax to get the file you could try this:
http://stackoverflow.com/questions/2235 ... -f5-reload

aka: setRequestHeader('Cache-Control', 'no-cache') before requesting the file. Also the second idea in that link is interesting. I don't have anything to test this with.
B
94
S
33
G
117
Posts: 5,391
Reputation: 75,343


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 4 guests