4 Replies Latest reply on Jul 26, 2013 6:42 AM by Mariano Colabraro

    XMLHttpRequest response is not cached locally



      I have a case where using XMLHttpRequest from within RhoElements is not cached. Every time you press the button to request this object is sent back to the browser (Rho) instead taking it from the cache.
      I ran the same test in Chrome and it works fine. It shows that the time of be call does not changes. That means that the object is read from the cache.


      I'm using MC67. RhoElements /
      Apache Tomcat, and a war application file to offer the REST service.


      Is it SyncEngine AJAX API the only way to do this?


      Thank you,

        • Re: XMLHttpRequest response is not cached locally


          Can you please try to use HTML5 offline cache.

            • Re: XMLHttpRequest response is not cached locally
              Pietro Francesco Maggi

              Hi Vinod,

              in this case we're trying to have an ajax request cached for more or less one hour.


              Implementing this with HTML application caching seems overkill and more error-proof that using the browser caching.


              I've logged the HTTP traffic from RhoElements (Shared Runtime or native apps makes no difference) and from Chrome, and there're no differences from the Tomcat server.

              Simply the motorola webkit browser ignore the cache setting:


              GET /testCache/resources/test/cached HTTP/1.1


              Connection: Keep-Alive

              Cookie: JSESSIONID=E5677A1ECC5F1F715543CB42B946A52F

              Accept-Encoding: gzip, deflate

              User-Agent: Mozilla/5.0 (MotorolaWebKit; U; /Windows CE 5.2) AppleWebKit/534.51 (KHTML, like Gecko) Version/ Mobile Safari/534.51


              Accept: */*

              HTTP/1.1 200 OK

              Server: Apache-Coyote/1.1

              Cache-Control: no-transform, max-age=3600

              Content-Type: application/json

              Transfer-Encoding: chunked

              Date: Wed, 24 Jul 2013 22:16:27 GMT

              Hello world! Timestamp: 2013-07-24 22:16:27.498

                • Re: XMLHttpRequest response is not cached locally




                  I guess Cache-Control is really ignored by motorola webkit browser and it looks like there are no ways to force browser to respect this header. I not sure it can be considered as a browser issue because nowhere stated it should use cached content in case of Cache-Control has been set properly. It just may be used.



                  IMHO it's quite uncommon XMLHttpRequest use case in your app. Typical cache control task with XMLHttpRequest is to disable cache for AJAX and it is a reverse task.



                  It shouldn't be a problem for AJAX request to reach server each time if response generation isn't resource/time consuming operation. In case it is resource or time consuming operation then you may implement server-side caching as a workaround.



                  Hope it helps,


                  1 of 1 people found this helpful