Skip navigation
chriskowalski
Currently Being Moderated

IE cache issue with Spry data table

Mar 13, 2008 6:56 AM

I am using a spry data table created in Dreamweaver CS3 on an .htm page with dynamic xml data that updates 1x an hour.
The .htm file and XML reside on the same server within the same folder on the server.
When I first view this page, everything displays correctly.
When the XML file is updated and FTP'd to this folder, the dynamic spry table in FireFox displays the new XML content, but IE6 does not display the new XML content.
In IE6, I hit the F5 key to refresh the page, and the XML content still does not display the current "fresh" data. When I manually in the IE6 browser go to TOOLS > INTERNET OPTIONS > DELETE temporary files to clear the cache. Then the new "fresh" XML content appears.

Here is the code I am using:
var ds1hydro2 = new Spry.Data.XMLDataSet("hydroplants.xml", "dataroot/HYDROPLANTS/HYDROPLANT",{useCache:false,loadInterval:3000}) ;

In the Live Docs information, it says:
"One other concern with dynamically generated XML is making sure
that the browser (or server) does not cache the data. Browser or server
caching can prevent your most recent data from reaching Spry. To prevent
this, specify HTTP headers for the following items: Cache-Control. Expires, and Pragma."

This is the http header info I used on the .htm page:
<META HTTP-EQUIV="expires" CONTENT="-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache, no-store">
<META HTTP-EQUIV="Cache-Control" CONTENT="private,
no-store, must-revalidate">

I have tried various combinations, but I cannot get the IE6 cache to clear.

Do I have an error in my code?
Am I using the correct meta http-equiv tags?
Is there an IE6 cache bug?

Any comment or help is appreciated.
 
Replies
  • Currently Being Moderated
    Mar 13, 2008 1:00 PM   in reply to chriskowalski
    I've run into the same and had a little luck with the following from the LiveDocs Spry:

    // Load the data every 10 seconds. Turn off the cache to make sure we get it directly from the server.
    var dsPhotos = new Spry.Data.XMLDataSet("/photos.php?galleryid=2000", "/gallery/photos/photo", { useCache: false, loadInterval:
    10000 });

    When you attach the dataset (XML) Adobe help recommends "Select the Turn XML Caching Off option if you want to load data directly from the server. By default, the Spry XML data set is loaded to a local cache on the user’s computer to improve performance, but if you have highly dynamic data, there is no advantage to this method.
    Select the Auto Refresh Data option and enter a value in milliseconds. If you select this option, the data set automatically refreshes the XML data from the server at the specified interval. This is helpful with data that changes frequently. "

    Like I said - I've had some success with just this, but it will load from the server every time (not cache).
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2008 5:57 AM   in reply to chriskowalski
    This is a real *&^%^ of a problem and it's taken me quite a while to find a solution; in fact, just got back from a friend's place who helped me out (thanks Steve).

    I wasn't doing auto refreshes, but same issue. I am simulating the browser back/forward buttons in a Spry data area by using a stack maintained in ColdFusion on the server, in session scope. Traversing back and forth, trimming the stack, breaking the stack when going to a new URL within the site after navigating back, etc, all worked exactly as expected in Firefox. In IE, it seemed to work until I wanted to go back into the stack then hit a new internal link. From that point on, it got sticky and behaved exactly as you wouldn't expect, which we traced to a caching of pages that couldn't be overridden with header tags or anything else we knew how to do.

    OK, to the solution, it is a Spry issue. [** oops, no it isn't exactly a Spry issue, it's IE failing to do what is expected, now there's a first. See Kin's reply below. ***] You both did what I did and followed the docs. My constructor looks like this:

    var dsContent = new Spry.Data.HTMLDataSet("index.cfm?fuseaction=public.home", "contentData", {useCache: false });

    In testing, when we set useCache: true, Firefox behaved exactly like IE, which gave us our clue.

    My less-than-perfect understanding suggests that the Spry code running in an IE6 browser session loses the useCache: false directive on the data object. Our work-around is to re-assert this after loading the data to the Spry data object. Here's how mine looks:

    dsContent.loadData(); useCache=false;

    Once we did this, IE behaved exactly like Firefox, and exactly to expectations. Anyone who really understands this stuff, please let us know if our work-around is safe and maybe the Adobe Spry team can provide something more elegant.

    Enjoy!

    Peter Robertson
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2008 12:32 PM   in reply to chriskowalski
    U can also add a unique value to your data so IE sees it as new content
    ------------
    var date = new Date();
    var unique = date.valueOf();

    var ds1hydro2 = new Spry.Data.XMLDataSet("hydroplants.xml?time="+unique, "dataroot/HYDROPLANTS/HYDROPLANT",{useCache:false,loadInterval:3000}) ;

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2008 2:21 PM   in reply to Arnout Kazemier
    Yes, also makes sense for auto-refresh situations. In my case, however, once the constructor runs it doesn't get noticed again as links outside of (and inside) my Spry data display load new (hopefully) data to the data object for display. I'll try to get a chance to test it as this would indicate that IE knows something about the data object. In any case, it is still a work-around and this will hopefully will get noticed and fixed by the team.

    Cheers

    Peter Robertson
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2008 2:35 PM   in reply to Peter Robertson
    Hi Peter (chollo),

    IE does have a caching bug. Spry is not losing the useCache setting on IE. When useCache is false, Spry makes an XmlHttpRequest for the URL you gave it, but it is then at the mercy of the caching rules defined by the browser and server, and as such, at the mercy of any bugs they have.

    You can see the same problem by using pure XmlHttpRequests (with no Spry involved). The way folks have been getting around this is the way V1Fusion points out, by adding a timestamp to the end of the URL which forces the browser to make the request, at the expense of more browser caching. Another possible workaround, is to use a POST instead of the default GET request. Try something like this:

    var ds1hydro2 = new Spry.Data.XMLDataSet("hydroplants.xml", "dataroot/HYDROPLANTS/HYDROPLANT",{useCache:false, loadInterval:3000, method: "POST"});

    And see if that gets you around the problem in IE. The reason this should work, is that browsers don't cache POST requests.

    --== Kin ==--
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2008 3:43 PM   in reply to chriskowalski
    Hi Kin

    Thanks for that, very good to know the why of it.
    Given that the kludge we found appears to work, do you see anything wrong with it?

    ie, reasserting the false value when loading the data subsequent to the constructor:
    dsContent.loadData(); useCache=false;

    (Mightn't be elegant, but it's simple :-) )

    Really appreciate the input. Do you think Adobe should reference these land mines directly in the Spry online docs?

    Cheers

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2008 4:28 PM   in reply to Peter Robertson
    Hi Peter,

    You are absolutely correct when you say we should be documenting these land mines. We have this on our list of todos as one of the things we need to document and provide a sample for.

    As for your workaround, I don't quite understand it:

    dsContent.loadData(); useCache=false;


    Do you mean??

    dsContent.loadData(); dsContent.useCache=false;

    I don't understand why that would make a difference since there is *NO* code within SpryData.js that ever sets the value of useCache except in the constructor of the data set. Have you actually verified with an alert() or Spry.Debug.trace() that useCache is indeed true when it was supposed to be false?

    --== Kin ==--
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2008 5:19 PM   in reply to kinblas
    Hi Kin

    No, haven't verified that the property gets lost. Given not understanding what happens under the covers, and verifying that Firefox behaved the same as IE when setting useCache=true in the constructor, we then went straw-clutching. The thing is, the code works when we use it, the stack I'm maintaining behaves perfectly well in IE as in Firefox and the behaviour of my code is as I expect. In other words, IE stops caching.

    If it doesn't look to you as though it should work, I'm going to take it out, as it may cause unpredictable effects with other browser types/versions. I've tested your solution and it works perfectly well (bearing in mind we're not auto refreshing, we are always loading data to the Spry data object from in-site links).

    So, for my understanding, having put the POST directive in the constructor, when I update the data object from a link, as in

    <a onclick=
    "dsContent.setURL('index.cfm?fuseaction=public.leftSubMenuItemPage&le ftNavSubID=435');
    dsContent.loadData();"
    >
    Personal Development Skills
    </a>

    ... how does this work? Does the data object then know that whenever it is asked to load any content, it must execute a post? I really don't understand.

    Anyway, it works, so I'll be using your POST solution.

    By the way, appears you're a Spry team member? Wasn't sure who I was talking to. Thanks for getting across this, and look forward to next Spry iteration.

    Cheers
     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2008 3:40 PM   in reply to Peter Robertson
    Hello everybody, I just try all the solutions you are writing here and in mi case it doesn't work, the really weird thing is that it work's some times and sometimes not, why?? all of you have try this just once? or you can confirm that it work's all the time?, cause in my case not, I know it is a IE bug, but it should be a walkaround for this, I use IE7 in vista, if anyones can tell me why?? thanks
     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2008 10:58 PM   in reply to chriskowalski
    goseta, there is a large topic about tacling this issue.

    eayest thing is to use post requests instead of get.

    var dataset = new Spry.Data.XMLDataSet('source.file','my/xpath',{method:'POST'});

    100% sure that works,

    same goes with my solution, also works 100%.
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 17, 2008 7:28 AM   in reply to chriskowalski
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 17, 2008 7:28 AM   in reply to chriskowalski
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2008 7:54 PM   in reply to Arnout Kazemier
    quote:

    Originally posted by: V1 Fusion
    goseta, there is a large topic about tacling this issue.

    eayest thing is to use post requests instead of get.

    var dataset = new Spry.Data.XMLDataSet('source.file','my/xpath',{method:'POST'});

    100% sure that works,

    same goes with my solution, also works 100%.


    When I put in method:"Post", IE doesn't display the xml data. :(
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2010 3:22 PM   in reply to bchau

    hey, bchau,

    I have the same problem with you.

    But i did try the other way mentioned above to get around.

     

     

    var date = new Date();
    var unique = date.valueOf();
    new Spry.Data.XMLDataSet("galleries/galleries.xml?time="+unique, "galleries/gallery",{useCache: false,loadInterval:3000});

     

    Anyone can explain to me why i can not get "{method::'POST'}"' working will be really great.!!!

     

    By the way, spry framework is really great, I truely love it.

    cheers!

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 23, 2010 4:30 AM   in reply to sprybeginner

    Thanks all for this discussion, it's just what I'm trying to solve. Unfortunately, I still have a combo of the issues.

    In Firefox, adding useCache:false to the constructor worked just fine.

     

    However,there seems to be new issues in IE8 (big surprise there), as this does not override caching.

    Adding dsname.useCache=false; also does not work.

     

    When I tried using the Post method in the constructor, Firefox 3.6 stops displaying the data set altogether, and IE8 is still using the cached data set, so unfortunately, the 100% works solution simply doesn't, at least with these versions of the browsers.

     

    Anyone have any clues on how to make FF, IE6, and IE8 all refresh the data set? I'm really only interested in it doing so when the page loads or reloads.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2011 4:56 AM   in reply to chriskowalski

    Hi everyone!

    I just realized that I have the exact same problem, found this post and tried adding  the method:'POST' thing.

    This solved the problem in IE7 but NOT in IE8.

     

     

    If somebody out there could help it would be much appreciated!

    /Annika

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points