Loading DATA, Updating Data(JOSN) and Images

Well, i must say I’m really fed up with Apple / Corona right now. I tried 1 million times, but I have no clue how to grab a remote file from the server in case it’s new. My iPhone (and more often the simulator) always grabs some old data (I have no idea where it’s coming from, it must be cached -SOMEWHERE).

Here’s what 'm trying:

Open a remote JSON file which contains version information. If the version is higher than the current version (9>6) then go ahead and load another new JSON with lots of new data (data.dat).

network.download( “http://www.path-to-server/live/version2.dat”, “GET”, networkListener_online,“version2.dat”, system.DocumentsDirectory )

The file ‘version.dat’ will appear in the project sandbox and I (and the iphone app) can read its contents.

Now I update the file on the server with my PC. I can clearly see its content (the name is the same!)

I run the corona project again (relaunch) and STILL there’s the old version-file in the sandbox.

I delete the file, I quit the simulator, I even cleared the Safari Cache. I restart my Mac.

I start the corona simulator. It will still “download” (?) the old (non-existing) file.

OK, I am deleting(!) the file from the server with my PC!

I run everything again, still same results: iphone simulator finds an old file and puts it in the sandbox (and it will -later- try to load some PNG-Files from the server that don’t exit anymore)…

I have the same problems with may remote calls from images, TEXT, XML,…)
Is there some cache and where can I delete it?

any help on this? I am really desperate…

[import]uid: 45296 topic_id: 8973 reply_id: 308973[/import]

I have no idea if the iphone does cache it (sounds like it does…) or how long the cache runs… but to bypass it why not just add a “?ts=”.os.time() to the end of the request so you’re always hitting a fresh url… The only concern is how long does the iphone keep the copies laying around… will it become a storage issue? [import]uid: 50570 topic_id: 8973 reply_id: 32780[/import]

I’ve noticed that EVEN when you specify a custom build-path for Corona to create an xCode app, that the “real” documents directory (for the app currently running under the sim) remains back in the normal path:
/Users/urName/Library/Application Support/iPhone Simulator/4.2/Applications

…not in the location that Corona show’s you for your just built app.

Hope this helps. [import]uid: 6175 topic_id: 8973 reply_id: 32784[/import]

To force the browser to grab a new version, you just need to append a random hash to the end of the URL. It’s not a specific Corona issue - most browsers or plugins like Flash implement this type of caching, and the workaround is the same in all cases.

Just do this:

myurl = “http://www.path-to-server/live/version2.dat”…tostring(math.random())
network.download( myurl , “GET”, networkListener_online,“version2.dat”, system.DocumentsDirectory )

or a similar strategy from jdsmith2816 above. The caching is dependent on what the HTTP headers specify from the server’s end.

Best,

  • Ian [import]uid: 238 topic_id: 8973 reply_id: 32943[/import]