I was wondering how to prevent Titanium.Network.HTTPClient
from caching my responseData
? This is happening on android in the directory /sdcard/Android/data/com.packagename/cache/_tmp
the files follow this pattern for their filename tihttp-XXXXXXXXXXXtmp
. I've already implemented a custom cache in the apps private data directory. So I don't need it to happen twice and waste the users precious data space on their sdcard. Plus the cache in the sdcard isn't always there.
Add a comment
|
1 Answer
var client = Ti.Network.createHTTPClient({
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
timeout : 5000,
cache : false,
});
The above works for iPhone only after a bit of looking, but if you set the headers directly to the request, it should work for both iPhone and Android:
client.setRequestHeader('Cache-Control','no-cache');
client.setRequestHeader('Cache-Control','no-store');
This must be called after open, but before the request is sent, i.e.:
var client = Ti.Network.createHTTPClient();
client.open('GET','http://google.com/');
client.setRequestHeader('Cache-Control','no-cache');
client.setRequestHeader('Cache-Control','no-store');
client.send('nice');
-
1In the docs it says that the cache properties default is false. So would it matter if I explicitly declare the cache property? Mar 28, 2013 at 15:05