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

Re: [OLmws] Ajax returning old data

Expand Messages
  • gpaslanis
    I agree! I do not see the benefit or the point in forcing a browser to pre-process cache based on an intentional unique GET request. To me the logical
    Message 1 of 15 , Oct 6, 2007
    • 0 Attachment
      I agree! I do not see the benefit or the point in forcing a browser to
      pre-process cache based on an intentional unique "GET" request. To me
      the logical choices are: OLgetAJAX(process cache) or OLpostAJAX(bypass
      cache). Short...Sweet... and to the point, but that's just my opinion.
    • easwiedler
      Thank you all for the input. It has helped greatly. I have tried using the OLpostAJAX call and it does just as you indicated it would. I now get fresh data
      Message 2 of 15 , Oct 7, 2007
      • 0 Attachment
        Thank you all for the input. It has helped greatly. I have tried
        using the OLpostAJAX call and it does just as you indicated it would.
        I now get "fresh" data every time.

        --- In overlibmws@yahoogroups.com, "Foteos Macrides" <fote@...> wrote:
        >
        > IE behaves like the other browsers with respect to caching of
        content returned via AJAX, and as you apparently desire, if you use
        POST instead of GET requests, i.e., if you use OLpostAJAX calls
        instead of OLgetAJAX calls. So invoking your
        Ajax_enrollment_details.asp script via OLpostAJAX is the simplest way
        to deal with the issue you raised, without need for any modifications
        in the ajaxcontentmws.js support script.
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: Foteos Macrides
        > To: overlibmws@yahoogroups.com
        > Sent: Saturday, October 06, 2007 4:56 PM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > I tracked down this caching problem. It is specific to IE (does
        not occur in Firefox, Opera or Safari). A simple and clear
        explanation is in the Known problems - Caching section of:
        >
        > http://en.wikipedia.org/wiki/XMLHttpRequest
        >
        > I want to think more about this issue before making any mods in
        the ajaxcontentmws.js support script (the problem would occur only
        transiently, for those users who are currently active, following any
        editing of an asp or php script for AJAX). In the meantime, should
        you frequently be editing your script, you can use prototype via the
        ALTERNATIVE FORMAT (see below) if as you indicated it includes a
        workaround for the IE caching problem.
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: Foteos Macrides
        > To: overlibmws@yahoogroups.com
        > Sent: Saturday, October 06, 2007 9:53 AM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > None of this happens if I use another Ajax component
        (prototype).
        > Use of prototype is fine for loading the popup content
        dynamically. See the ALTERNATIVE FORMAT example in:
        >
        > http://www.macridesweb.com/oltest/AJAX.html
        >
        > At this point, it appears you would need to provide a URL for a
        test example which exhibits the problem you are having with OLgetAJAX
        and is publicly accessible, so that we might see more fully what
        markup you are using and what is happening, and then try to diagnose
        the problem. Otherwise, if prototype works for you then you could
        simply stick with that.
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: easwiedler
        > To: overlibmws@yahoogroups.com
        > Sent: Friday, October 05, 2007 1:06 PM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > The value for EnrollmentID is filled by the server at the
        time the page is created. The issue is not that the wrong
        EnrollmentID is being used, rather that the data returned is stale.
        For instance, if I view the Ajax result, close it, make a change to
        the data and then open the Ajax view again, I get the original data.
        >
        > As I also said, if I load a static page via the Ajax call and
        then change the page, the next load via Ajax will get the original
        page. None of this happens if I use another Ajax component
        (prototype).
        > ----- Original Message -----
        > From: Foteos Macrides
        > To: overlibmws@yahoogroups.com
        > Sent: Thursday, October 04, 2007 11:41 AM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > The value for EnrollmentID is populated when the page
        loads, as it should be. That value is correct when passed to the
        Ajax call. The issue is that the data retrieved is not formatted
        correctly. By that I mean that, after changing the ASP program to
        format the data, the changes do not appear.
        > If I now understand you correctly, you do want your server
        to fill in the value of EnrollmentID at the time the overall document
        is served, in which case the OLgetAJAX call will keep using that
        value in the query string for your Ajax_enrollment_details.asp
        script. Because you are not using a css argument in your OLgetAJAX
        call, the value of OLresponseAJAX should become the unaltered value
        of the OLhttp.responseText string returned by your
        Ajax_enrollment_details.asp script. You can see if your script in
        fact is returning what you intend by adding:
        >
        > alert('OLhttp.responseText:\n' + OLhttp.responseText);
        >
        > in your ShowEnrollmentDetails function (before its return
        statement).
        >
        > But I'm still unclear on what you mean by "not formatted
        correctly" and "do not appear." Are you saying that "formatting"
        characters (markup) in the string returned by your
        Ajax_enrollment_details.asp script (and shown via an alert call if
        you add that to your ShowEnrollmentDetails function) are not what you
        intended, or that the string's "formatting" (meaning display style)
        in the overlib popup invoked via your ShowEnrollmentDetails function
        is not as you intended?
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: easwiedler
        > To: overlibmws@yahoogroups.com
        > Sent: Thursday, October 04, 2007 8:42 AM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > The value for EnrollmentID is populated when the page
        loads, as it should be. That value is correct when passed to the Ajax
        call. The issue is that the data retrieved is not formatted
        correctly. By that I mean that, after changing the ASP program to
        format the data, the changes do not appear.
        >
        > I further found that, when displaying a static page via
        this method, changes to that page are not realized until I restart
        the browser.
        >
        > ----- Original Message -----
        > From: Foteos Macrides
        > To: overlibmws@yahoogroups.com
        > Sent: Tuesday, October 02, 2007 8:28 PM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > Note they my reply had some uncaught typos, most of
        which are obvious, but be sure to include the semicolon after both of
        the HTML entity names:
        >
        > <%=EnrollmentID%>
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: Foteos Macrides
        > To: overlibmws@yahoogroups.com
        > Sent: Tuesday, October 02, 2007 3:33 PM
        > Subject: Re: [OLmws] Ajax returning old data
        >
        >
        > Note that the OLgetAJAX function makes an OLclearAJAX
        call internally to clear any pending AJAX request before initiating a
        new one, so you don't need to include that OLclearAJAX call before
        the OLgetAJAX call in your onclick attribute value.
        >
        > The way you have the first argument of the OLgetAJAX
        call presently, the server will replace the:
        >
        > <%=EnrollmentID%>
        >
        > with the value of EnrollmentID at the time the
        overall document is sent to the browser, and so any subsequent
        OLgetAJAX calls will use that initial value. Try changing the angle
        brackets to HTML entities:
        >
        > <%=EnrollmentID%>
        >
        > so that no substitution if done by the server in the
        overall document, and the browser's HTML parser convert's the
        entities to raw angle brackets before passing that argument on to the
        browser's javascript parser. Then, what I presume you actually want
        in the AJAX request should get sent to the server (i.e., to be filled
        in by whatever the current value of EnrollmentID is at the server).
        >
        > However, I'm not certain that's what you intend,
        because I would expect EnrollmentID to get updated if you re-load the
        entire document, and from what you indicate that doesn't seem to
        occur. So if the above doesn't solve your problem, please explain
        how EnrollmentID can get changed after fetches of the entire document
        but before an AJAX request is sent.
        >
        > Fote
        > --
        >
        > ----- Original Message -----
        > From: easwiedler
        > To: overlibmws@yahoogroups.com
        > Sent: Tuesday, October 02, 2007 9:50 AM
        > Subject: [OLmws] Ajax returning old data
        >
        >
        > First, I am duly impressed with this package!
        >
        > Second, I am having a problem with Ajax returning
        stale data.
        >
        > I have a page with a table listing several items.
        For each item, I define a link with an onClick handler as follows:
        >
        > <a class="button" href="javascript:void()"
        onClick="OLclearAJAX();
        > OLgetAJAX('../asp/Ajax_enrollment_details.asp?
        EnrollmentID=<%
        > =EnrollmentID%>', ShowEnrollmentDetails); return
        false;">view</a>
        >
        > The function in the parent page to display the
        results is:
        >
        > function ShowEnrollmentDetails() {
        > return overlib(OLresponseAJAX , TEXTPADDING,0,
        CAPTIONPADDING,4,
        > CAPTION,'Enrollment Details', WRAP, BORDER,2,
        STICKY, CLOSECLICK,
        > SCROLL, MIDX,0, RELY,100);
        > }
        >
        >
        > The ASP program returned an HTML fragment (just a
        table with the information). When I noticed that the data returned
        was stale, I thought that I needed to include the following in the
        headers:
        >
        > <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
        >
        > When this had no effect, I changed the ASP program
        to build an entire page (including the above line). The effect was
        unchanged. The only way I have found to get current data is to close
        the browser and restart which starts a new session. Re-loading the
        page had no effect (including forcing a re-load from the server).
        >
        > I am running IIS 5.0 on Windows 2000 as the server
        >
      • Foteos Macrides
        Here s some more information about cache handling with AJAX that may be of interest. It s true that any Cache-Control headers presented via http or meta tags
        Message 3 of 15 , Oct 12, 2007
        • 0 Attachment
          Here's some more information about cache handling with AJAX that may be of interest.
           
          It's true that any Cache-Control headers presented via http or meta tags for the overall document do not apply to the AJAX responses via the XMLHttpRequest object (or its ActiveX predecessor in IE).  But if your ASP or PHP (or Perl, etc.) script for handling the AJAX requests supplements the obligatory Content-Type header with a Cache-Control header, that is respected by IE and the other supported browsers.  So if your script were to include
           
          Content-Type: . . . 
          Cache-Control: no-cache
           
          when replying to a GET request via OLgetAJAX, then the response will not be cached, as if you had used a POST request via OLpostAJAX.
           
          But not caching the response is inefficient and wastes bandwidth if you are only concerned with an IE user who is being tracked via an "EnrollmentID" getting the (only occasionally, for formatting rather than critical content) edited version of an AJAX response starting relatively soon after the editing, rather than having to wait until whenever the user invokes a new instance of IE.  In principle, the way to deal with that while still using GET requests and caching is to force only "If-Modified-Since" checks, by having your script send:
           
          Content-Type: . . . 
          Last-Modified: . . . 
          Cache-Control: must-revalidate
           
          That works with the non-IE browsers, but unfortunately not IE.
           
          The next best alternative, which does work with IE as well as the non-IE browsers, is to impose an expiration on the cached response, e.g., 10 min (600 seconds):
           
          Content-Type: . . . 
          Cache-Control: max-age=600
           
          Fote
          --
           
          ----- Original Message -----
          From: gpaslanis
          Sent: Saturday, October 06, 2007 10:32 PM
          Subject: Re: [OLmws] Ajax returning old data

          I agree!  I do not see the benefit or the point in forcing a browser to pre-process cache based on an intentional unique "GET" request.  To me the logical choices are: OLgetAJAX(process cache) or OLpostAJAX(bypass cache).  Short...Sweet... and to the point, but that's just my opinion.
        Your message has been successfully submitted and would be delivered to recipients shortly.