5 Replies Latest reply on Sep 23, 2009 6:56 PM by Qingqing Chen

    About HttpService cache

    Qingqing Chen

      I have an issue about HttpService refresh. My case is I need to download a .cvs file to fetch data.


      I have searched on internet. There are serveral answers here. I have tried some like the following:


                1. add a faked parameter using new date()

                2. change Html template to add

                                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                                    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
                                    <META HTTP-EQUIV="expires" CONTENT="0">  ...

                3. add no-cache to HttpService header


      none of this works. For the .cvs file from Yahoo. I even cleaned my "C:\Documents and Settings\XXX\Local Settings\Temporary Internet Files". Every

      time I run the flex application. I saw a cvs created with timestamp but old content. More weird, I put a cvs on my local tomcat web service. It can not refresh by click IE refresh button. But it can refresh in new open IE. (cvs from yahoo never refresh).


      Internet Explorer:  version 6.0 with patch 2

      Mozilla firefox:


      PS: Yahoo cvs changes by day.


      I attached the the code following





      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  creationComplete="init()">

         import mx.rpc.events.ResultEvent;
         import mx.controls.Alert;

         public var csvText:String;
         private function init():void{
      //    csv.headers = {"Cache-Control":"no-cache", "Pragma":"no-cache"};
          csv.url = csv.url +"&xxxyyy="+ new Date().valueOf();
      //     csv.url = ""+"&#0038;xxxyyy="+ new Date().valueOf();
         private function resultHanlder(event:ResultEvent):void{
          csvText = event.result as String;
         private function faultHanlder(event:Event):void{

      <mx:HTTPService id="csv" result="resultHanlder(event)" fault="faultHanlder(event)"
         resultFormat="text" showBusyCursor="true" method="post"
        url="http://ichart.finance.yahoo.com/table.csv?s=%5EDJI&#0038;d=8&#0038;e=14&#0038;f=2009&#0038 ;g=d&#0038;a=9&#0038;b=1&#0038;c=1928&#0038;ignore=.csv"/>
        <mx:TextArea text="{csvText}" width="100%" height="100%"/>

        • 1. Re: About HttpService cache
          flashharry! Level 1

          You need to generate a unique url each time, I use math random to archive this, Note code shorten space.

                    private function init() : void {
                     httpService.url = "";


                     //Create a new object to hold parameters
                     var getParametersInit:Object = new Object();
                     getParametersInit._cmd ='getCommandForServerScript';
                     getParametersInit.someparameter = "parameterInfoToPass";


                    //Create a random number to ensure read from server and not cahce

                     getParametersInit.nocache = Math.random();
                     //Now assign the parameter + value object to httpservice
                     httpService.request = getParametersInit;



          <HTTPService id="httpAjaxService"
          1 person found this helpful
          • 2. Re: About HttpService cache
            msakrejda Level 4

            Method (1) should always work (and indeed, it does work for us)--no one should be caching things with different request strings. Can you investigate the network traffic (with a sniffer like Wireshark) and server logs to verify what exactly is being requested and what is being sent?

            1 person found this helpful
            • 3. Re: About HttpService cache
              Qingqing Chen Level 1

              thanks for the previous responses. But I don't think it address the issue.



              private function init():void{
              //    csv.headers = {"Cache-Control":"no-cache", "Pragma":"no-cache"};
                 csv.url = csv.url +"&xxxyyy="+ new Date().valueOf();
              //     csv.url = ""+"&#0038;xxxyyy="+ new Date().valueOf();



              This method is called every time when Application is creationComplete. you can see that l have added a timestamp &xxxyyy= some numbers to url.


              But it nerver refresh whether I click IE refresh button or open a new IE. I also inspect the  "C:\Documents and Settings\XXX\Local Settings\Temporary Internet Files" directory. And I did see some new file similiar to table.cvs?****&xxxyyy=2323232 create. It is old content.


              Please try my provided code!  It is simple.

              • 4. Re: About HttpService cache
                flashharry! Level 1

                I tried your code and it worked for me, I created a server side script that sent back a unique number each time, each refresh I got a new number?

                SDK 3.4.0

                Have you tested the url in a browser window to that the server is sending fresh data correctly?

                • 5. Re: About HttpService cache
                  Qingqing Chen Level 1

                  Thanks you all for friendly responses. The problem is the url. It should be only http://ichart.finance.yahoo.com/table.csv?s=%5EDJI. The other parameters will limit the date of data. And there is no bussiness of httpservice cache.