How to force data not to load from cache?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luke14free
    New Member
    • Apr 2007
    • 79

    How to force data not to load from cache?

    Goodmorning, I am doing a WebSite with ajax and other things...
    I have got a problem, IE has a bug that doesnt recognize the ajax command that loads xml files not from cache {UseCache:false } (that Firefox recognizes without problems...).
    I tried many others way but i wasn't able to disable caching...
    Any Ideas?
    Thanks,
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    try this

    [HTML]<META HTTP-EQUIV="Pragma" CONTENT="no-cache">[/HTML]
    or
    [PHP]header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires : Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    [/PHP]
    place that in your head tag

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Once Your Question Has Been Answered
      When you have gotten your answer, please post back with something like "Thanks, that answers my question" so the thread can be closed and people who are looking for unanswered questions can find them more easily.

      Comment

      • luke14free
        New Member
        • Apr 2007
        • 79

        #4
        Sorry but I tried that too...no way the code doesnt work...old data is loaded

        Comment

        • epots9
          Recognized Expert Top Contributor
          • May 2007
          • 1352

          #5
          did u clear your cache before u applied the new lines of code? cuz its from this point one where it doesn't cache but if it was there before it stays there until its expired.

          Comment

          • luke14free
            New Member
            • Apr 2007
            • 79

            #6
            Code:
            <script type="text/javascript">
            <!--
            var d = new Date()
            var ds1 = new Spry.Data.XMLDataSet("data.xml?cacheBuster=" + d.getMilliseconds(), "events/event",{useCache:false});
            //-->
            </script>
            thanks, solved...

            Comment

            • bucabay
              New Member
              • Apr 2007
              • 18

              #7
              Originally posted by luke14free
              Code:
              <script type="text/javascript">
              <!--
              var d = new Date()
              var ds1 = new Spry.Data.XMLDataSet("data.xml?cacheBuster=" + d.getMilliseconds(), "events/event",{useCache:false});
              //-->
              </script>
              thanks, solved...
              I know this is considered solved, but I want to mention that:

              These cache problems are because you're using HTTP GET Requests. If you don't want a your XMLHTTPRequests to be cached, use a HTTP POST. Thats what it's for...

              see: http://fijiwebdesign.com/content/view/92/77/

              If you're really worried about it caching so much, then use unique URIs for your HTTP POST.

              eg: pseudo code:

              Code:
              XHR.post('example?no-cache='+(new Date()).getMilliseconds()).send(data);

              Comment

              • ak1dnar
                Recognized Expert Top Contributor
                • Jan 2007
                • 1584

                #8
                Another way of omit the cache is sending unique requests to to the server side scripts.

                for a example:

                Code:
                var url="server_side_page.php?some_data="+value_goes_here;
                url=url+"&request="+Math.random();
                then send it to the server side for processing.

                Comment

                Working...