Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

setRequestHeader and If-Modified-Since doesnt reply a 304 status

I cant use setRequestHeader with "If-Modified-Since" to get back at 304 Status.

I want to use this for storing images and xml files on the device.

And everytime the xml or the image is requested by the application it should check if a newer version is found on the server.

Im sending the date "Mon, 19 Jul 2010 11:20:22 GMT"

And im receiving the date "Mon, 19 Jul 2010 10:20:17 GMT" from the server.

Usually it should work and return a 304 status.

if (Titanium.Network.online)
{
      var c = Titanium.Network.createHTTPClient();
      if (c.status == 304)
      {
        // XML File not necessary - Clientlog File is newer
        console.log('Use Client XML File - is newer than the server XML');
        fn_end(file_obj);
        return;
      }
      // ...here will follow some code to store the files on the device

      c.open('GET', url);
      c.setRequestHeader("If-Modified-Since", "Mon, 19 Jul 2010 11:20:22 GMT");
      c.send();
}
— asked July 19th 2010 by Marco Schierhorn
  • 304
  • header
  • if-modified-since
  • mobile
  • setrequestheader
0 Comments

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.