Loading ...
Sorry, an error occurred while loading the content.

Problem for SetInterval for GET data from connetion manager

Expand Messages
  • wejiangwe
    I am working on getting data from server by YUI library. The data should be displayed dynamically for every second. I tried to use the code below, but it
    Message 1 of 13 , Apr 25, 2007
    • 0 Attachment
      I am working on getting data from server by YUI library. The data
      should be displayed dynamically for every second.

      I tried to use the code below, but it always return the same data, it
      seems YAHOO.util.Connect.asyncRequest always return the same object.

      setInterval("YAHOO.util.Connect.asyncRequest('GET', sUrl, callback)",
      1000);

      Any suggestions? How can I get the request for every second? Thank you
      in advance!
    • tssha
      ... Without knowing more about the details and data, I d say your requests are being cached. Serve a cache-busting header, or add a randomised sequence to
      Message 2 of 13 , Apr 25, 2007
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "wejiangwe" <wejiangwe@...> wrote:
        >
        > I am working on getting data from server by YUI library. The data
        > should be displayed dynamically for every second.
        >
        > I tried to use the code below, but it always return the same data, it
        > seems YAHOO.util.Connect.asyncRequest always return the same object.
        >
        > setInterval("YAHOO.util.Connect.asyncRequest('GET', sUrl, callback)",
        > 1000);
        >
        > Any suggestions? How can I get the request for every second? Thank you
        > in advance!

        Without knowing more about the details and data, I'd say your requests
        are being cached. Serve a cache-busting header, or add a randomised
        sequence to your querystring.

        Regards,
        Thomas
      • wejiangwe
        Thank you so much, Thomas. Could you please tell more about Serve a cache-busting header, or add a randomised sequence to your querystring ? Are there any
        Message 3 of 13 , Apr 25, 2007
        • 0 Attachment
          Thank you so much, Thomas.

          Could you please tell more about "Serve a cache-busting header, or
          add a randomised sequence to your querystring"?
          Are there any examples in YUI?

          --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
          >
          > --- In ydn-javascript@yahoogroups.com, "wejiangwe" <wejiangwe@>
          wrote:
          > >
          > > I am working on getting data from server by YUI library. The
          data
          > > should be displayed dynamically for every second.
          > >
          > > I tried to use the code below, but it always return the same
          data, it
          > > seems YAHOO.util.Connect.asyncRequest always return the same
          object.
          > >
          > > setInterval("YAHOO.util.Connect.asyncRequest('GET', sUrl,
          callback)",
          > > 1000);
          > >
          > > Any suggestions? How can I get the request for every second?
          Thank you
          > > in advance!
          >
          > Without knowing more about the details and data, I'd say your
          requests
          > are being cached. Serve a cache-busting header, or add a
          randomised
          > sequence to your querystring.
          >
          > Regards,
          > Thomas
          >
        • Gopalarathnam Venkatesan
          ... Suffixing something like &rand= + (new Date().getTime()) or, &rand= + (Math.random()) should do. -- Gopalarathnam Venkatesan http://gopalarathnam.com/
          Message 4 of 13 , Apr 25, 2007
          • 0 Attachment
            wejiangwe wrote:
            >
            >
            > Thank you so much, Thomas.
            >
            > Could you please tell more about "Serve a cache-busting header, or
            > add a randomised sequence to your querystring"?

            Suffixing something like "&rand=" + (new Date().getTime()) or, "&rand="
            + (Math.random()) should do.


            --
            Gopalarathnam Venkatesan

            http://gopalarathnam.com/
          • wejiangwe
            Thank you, Gopalarathnam. I understand the add a randomised sequence now. But I don t think it is a good way to change the parameter every time. I tried to
            Message 5 of 13 , Apr 27, 2007
            • 0 Attachment
              Thank you, Gopalarathnam. I understand the "add a randomised
              sequence" now. But I don't think it is a good way to change the
              parameter every time.

              I tried to "Serve a cache-busting header", such as
              YAHOO.util.Connect.initHeader('CACHE-CONTROL', 'NO-CACHE');
              But it seems doesn't work, still cached. :(


              --- In ydn-javascript@yahoogroups.com, Gopalarathnam Venkatesan
              <gopal@...> wrote:
              >
              > wejiangwe wrote:
              > >
              > >
              > > Thank you so much, Thomas.
              > >
              > > Could you please tell more about "Serve a cache-busting header,
              or
              > > add a randomised sequence to your querystring"?
              >
              > Suffixing something like "&rand=" + (new Date().getTime())
              or, "&rand="
              > + (Math.random()) should do.
              >
              >
              > --
              > Gopalarathnam Venkatesan
              >
              > http://gopalarathnam.com/
              >
            • tssha
              ... Issue the header from the server, not from the client/Connection Manager. Regards, Thomas
              Message 6 of 13 , Apr 27, 2007
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, "wejiangwe" <wejiangwe@...> wrote:
                >
                > Thank you, Gopalarathnam. I understand the "add a randomised
                > sequence" now. But I don't think it is a good way to change the
                > parameter every time.
                >
                > I tried to "Serve a cache-busting header", such as
                > YAHOO.util.Connect.initHeader('CACHE-CONTROL', 'NO-CACHE');
                > But it seems doesn't work, still cached. :(

                Issue the header from the server, not from the client/Connection Manager.

                Regards,
                Thomas
              • wejiangwe
                ... Manager. ... Thanks, Thomas! I tested the server, it seems not the problem from server. I inputed the url to browser directly, refresh every second
                Message 7 of 13 , Apr 30, 2007
                • 0 Attachment
                  --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
                  >
                  > --- In ydn-javascript@yahoogroups.com, "wejiangwe" <wejiangwe@>
                  wrote:
                  > >
                  > > Thank you, Gopalarathnam. I understand the "add a randomised
                  > > sequence" now. But I don't think it is a good way to change the
                  > > parameter every time.
                  > >
                  > > I tried to "Serve a cache-busting header", such as
                  > > YAHOO.util.Connect.initHeader('CACHE-CONTROL', 'NO-CACHE');
                  > > But it seems doesn't work, still cached. :(
                  >
                  > Issue the header from the server, not from the client/Connection
                  Manager.
                  >
                  > Regards,
                  > Thomas
                  >

                  Thanks, Thomas! I tested the server, it seems not the problem from
                  server. I inputed the url to browser directly, refresh every second
                  manually, it is not cached, shows the latest data.

                  Could you please tell me any other ways to how to clear the cache by
                  Yahoo library?
                • Mike Lee (YUI)
                  Hi wejiangwe, Could you provide a URL or send some code that shows this issue? If the file is not being cached and both techniques (adding a randomized
                  Message 8 of 13 , Apr 30, 2007
                  • 0 Attachment
                    Hi wejiangwe,

                    Could you provide a URL or send some code that shows this issue? If the
                    file is not being cached and both techniques (adding a randomized
                    sequence and serving a cache-busting header) did not work, perhaps the
                    source of the issue is elsewhere in your implementation.

                    Thanks!


                    ________________________________

                    From: ydn-javascript@yahoogroups.com
                    [mailto:ydn-javascript@yahoogroups.com] On Behalf Of wejiangwe
                    Sent: Monday, April 30, 2007 9:15 AM
                    To: ydn-javascript@yahoogroups.com
                    Subject: [ydn-javascript] Re: Problem for SetInterval for GET data from
                    connetion manager


                    --- In ydn-javascript@yahoogroups.com
                    <mailto:ydn-javascript%40yahoogroups.com> , "tssha" <tsha@...> wrote:
                    >
                    > --- In ydn-javascript@yahoogroups.com
                    <mailto:ydn-javascript%40yahoogroups.com> , "wejiangwe" <wejiangwe@>
                    wrote:
                    > >
                    > > Thank you, Gopalarathnam. I understand the "add a randomised
                    > > sequence" now. But I don't think it is a good way to change the
                    > > parameter every time.
                    > >
                    > > I tried to "Serve a cache-busting header", such as
                    > > YAHOO.util.Connect.initHeader('CACHE-CONTROL', 'NO-CACHE');
                    > > But it seems doesn't work, still cached. :(
                    >
                    > Issue the header from the server, not from the client/Connection
                    Manager.
                    >
                    > Regards,
                    > Thomas
                    >

                    Thanks, Thomas! I tested the server, it seems not the problem from
                    server. I inputed the url to browser directly, refresh every second
                    manually, it is not cached, shows the latest data.

                    Could you please tell me any other ways to how to clear the cache by
                    Yahoo library?
                  • wejiangwe
                    Thank you, Mike. The URL is internal, it seems cannot show external. I added the randomized sequence, it works, but my boss thinks it is not a good way. For
                    Message 9 of 13 , May 1, 2007
                    • 0 Attachment
                      Thank you, Mike.
                      The URL is internal, it seems cannot show external.
                      I added the randomized sequence, it works, but my boss thinks it is
                      not a good way.

                      For serving a cache-busting header, I tried to add "Cache-Control"
                      to "No-cache" on the header, but doesn't work.

                      And there are other issues for datasource utility, eventually we
                      abadon to use YUI library.

                      Anyway, thank you so much for help.

                      --- In ydn-javascript@yahoogroups.com, "Mike Lee \(YUI\)"
                      <mikelee@...> wrote:
                      >
                      > Hi wejiangwe,
                      >
                      > Could you provide a URL or send some code that shows this issue?
                      If the
                      > file is not being cached and both techniques (adding a randomized
                      > sequence and serving a cache-busting header) did not work, perhaps
                      the
                      > source of the issue is elsewhere in your implementation.
                      >
                      > Thanks!
                      >
                      >
                      > ________________________________
                      >
                      > From: ydn-javascript@yahoogroups.com
                      > [mailto:ydn-javascript@yahoogroups.com] On Behalf Of wejiangwe
                      > Sent: Monday, April 30, 2007 9:15 AM
                      > To: ydn-javascript@yahoogroups.com
                      > Subject: [ydn-javascript] Re: Problem for SetInterval for GET data
                      from
                      > connetion manager
                      >
                      >
                      > --- In ydn-javascript@yahoogroups.com
                      > <mailto:ydn-javascript%40yahoogroups.com> , "tssha" <tsha@> wrote:
                      > >
                      > > --- In ydn-javascript@yahoogroups.com
                      > <mailto:ydn-javascript%40yahoogroups.com> , "wejiangwe"
                      <wejiangwe@>
                      > wrote:
                      > > >
                      > > > Thank you, Gopalarathnam. I understand the "add a randomised
                      > > > sequence" now. But I don't think it is a good way to change
                      the
                      > > > parameter every time.
                      > > >
                      > > > I tried to "Serve a cache-busting header", such as
                      > > > YAHOO.util.Connect.initHeader('CACHE-CONTROL', 'NO-CACHE');
                      > > > But it seems doesn't work, still cached. :(
                      > >
                      > > Issue the header from the server, not from the client/Connection
                      > Manager.
                      > >
                      > > Regards,
                      > > Thomas
                      > >
                      >
                      > Thanks, Thomas! I tested the server, it seems not the problem from
                      > server. I inputed the url to browser directly, refresh every
                      second
                      > manually, it is not cached, shows the latest data.
                      >
                      > Could you please tell me any other ways to how to clear the cache
                      by
                      > Yahoo library?
                      >
                    • tssha
                      ... How so? ... There isn t just one solution. Issue a far-past Expires header and, or a Last-Modified header that insures every cached result is instantly
                      Message 10 of 13 , May 1, 2007
                      • 0 Attachment
                        --- In ydn-javascript@yahoogroups.com, "wejiangwe" <wejiangwe@...> wrote:
                        >
                        > Thank you, Mike.
                        > The URL is internal, it seems cannot show external.
                        > I added the randomized sequence, it works, but my boss thinks it is
                        > not a good way.

                        How so?

                        > For serving a cache-busting header, I tried to add "Cache-Control"
                        > to "No-cache" on the header, but doesn't work.

                        There isn't just one solution.

                        Issue a far-past Expires header and, or a Last-Modified header that
                        insures every cached result is instantly outdated.

                        Even the Cache-Control has more options that you're showing. For example:
                        header("Cache-Control: no-store, no-cache, must-revalidate");
                        header("Cache-Control: post-check=0, pre-check=0", false);

                        Regards,
                        Thomas
                      • Gopalarathnam Venkatesan
                        ... Just curious to know what issues you are facing with YUI. -- Gopalarathnam Venkatesan http://gopalarathnam.com/
                        Message 11 of 13 , May 1, 2007
                        • 0 Attachment
                          wejiangwe wrote:
                          >
                          >
                          > Thank you, Mike.
                          > The URL is internal, it seems cannot show external.
                          > I added the randomized sequence, it works, but my boss thinks it is
                          > not a good way.
                          >
                          > For serving a cache-busting header, I tried to add "Cache-Control"
                          > to "No-cache" on the header, but doesn't work.
                          >
                          > And there are other issues for datasource utility, eventually we
                          > abadon to use YUI library.
                          >

                          Just curious to know what issues you are facing with YUI.

                          --
                          Gopalarathnam Venkatesan

                          http://gopalarathnam.com/
                        • wejiangwe
                          I don t know that issue clearly, my co-worker said when we tried to implement custom sorting, we ran into problems that we re unable to access other column
                          Message 12 of 13 , May 1, 2007
                          • 0 Attachment
                            I don't know that issue clearly, my co-worker said when we tried to
                            implement custom sorting, we ran into problems that we're unable to
                            access other column values in the same row. Therefore redundant
                            string parsing had to be done which is a serious limitation.

                            Any suggestion?


                            --- In ydn-javascript@yahoogroups.com, Gopalarathnam Venkatesan
                            <gopal@...> wrote:
                            >
                            > wejiangwe wrote:
                            > >
                            > >
                            > > Thank you, Mike.
                            > > The URL is internal, it seems cannot show external.
                            > > I added the randomized sequence, it works, but my boss thinks it
                            is
                            > > not a good way.
                            > >
                            > > For serving a cache-busting header, I tried to add "Cache-
                            Control"
                            > > to "No-cache" on the header, but doesn't work.
                            > >
                            > > And there are other issues for datasource utility, eventually we
                            > > abadon to use YUI library.
                            > >
                            >
                            > Just curious to know what issues you are facing with YUI.
                            >
                            > --
                            > Gopalarathnam Venkatesan
                            >
                            > http://gopalarathnam.com/
                            >
                          • Mike Lee (YUI)
                            ... By the way, using a randomized sequence in a URL is a common practice used by a lot of large web applications. The disadvantages of using unique URLs like
                            Message 13 of 13 , May 2, 2007
                            • 0 Attachment
                              > Thank you, Mike.
                              > The URL is internal, it seems cannot show external.
                              > I added the randomized sequence, it works, but my boss thinks it is
                              > not a good way.

                              By the way, using a randomized sequence in a URL is a common practice
                              used by a lot of large web applications. The disadvantages of using
                              unique URLs like this is that they cannot be bookmarked - but since
                              you're trying to defeat the cache and this file is not accessible by end
                              users, bookmarking is no concern.

                              I don't want to cause you any trouble with your boss, but just so you
                              know, using randomized sequences in URLs for your particular use case is
                              a common practice and isn't considered harmful by many. Using
                              server-side techniques may be cleaner, but randomized sequences aren't
                              necessarily bad.

                              In any case, good luck with your application!



                              ________________________________

                              From: ydn-javascript@yahoogroups.com
                              [mailto:ydn-javascript@yahoogroups.com] On Behalf Of wejiangwe
                              Sent: Tuesday, May 01, 2007 9:58 AM
                              To: ydn-javascript@yahoogroups.com
                              Subject: [ydn-javascript] Re: Problem for SetInterval for GET data from
                              connetion manager


                              Thank you, Mike.
                              The URL is internal, it seems cannot show external.
                              I added the randomized sequence, it works, but my boss thinks it is
                              not a good way.

                              For serving a cache-busting header, I tried to add "Cache-Control"
                              to "No-cache" on the header, but doesn't work.

                              And there are other issues for datasource utility, eventually we
                              abadon to use YUI library.

                              Anyway, thank you so much for help.
                            Your message has been successfully submitted and would be delivered to recipients shortly.