CodingIE Caching Issue

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  ANT_THOMAS  
 To:  ALL
33956.1 
I'm sorting out my blog/map/tracker thing for my hitchike to Tallinn and I've come across a problem with IE and how it handles to data for the marker points.

They're held in a file cunningly named "markers.txt", after previously having to update the txt file manually I decided to get my coding cap on and make it possible to update via a little form online. Far easier than downloading, editing and reuploading.

Anyway, when I update the markers file and refresh in IE the new markers aren't there. When I refresh in Firefox the new ones are there. I assume IE is just caching the file and just using that. Even Ctrl+F5 doesn't force it to download the markers.txt file again.

The code for the sidebar and for the markers to be placed is:

Java Script code:
<script type="text/javascript">
    //<![CDATA[
 
    if (GBrowserIsCompatible()) {
      // this variable will collect the html which will eventually be placed in the side_bar
      var side_bar_html = "";
    
      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;
 
 
      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        htmls[i] = html;
        // add a line to the side_bar html
        side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
        i++;
        return marker;
      }
 
 
      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }
 
 
      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(53.386719, -1.503507), 8);
 
      var side_bar_html = "";
      
      // === Define the function thats going to process the text file ===
      process_it = function(doc) {
        // === split the document into lines ===
        lines = doc.split("\n");
        for (var i=0; i<lines.length; i++) {
          if (lines[i].length > 1) {
            // === split each line into parts separated by "|" and use the contents ===
            parts = lines[i].split("|");
            var lat = parseFloat(parts[0]);
            var lng = parseFloat(parts[1]);
            var html = parts[2];
            var label = parts[3];
            var point = new GLatLng(lat,lng);
            // create the marker
            var marker = createMarker(point,label,html);
            map.addOverlay(marker);
          }
        }
        // put the assembled side_bar_html contents into the side_bar div
        document.getElementById("side_bar").innerHTML = side_bar_html;
      }          
          
      GDownloadUrl("markers.txt", process_it);
    }
 
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
   
 
    //]]>
    </script>


I added a "?" here:

code:
GDownloadUrl("markers.txt?", process_it);


Which did nothing.

Anyone with a simple fix?

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.2 In reply to 33956.1 
(Disclaimer: I'm tired; I may be talking nonsense.)

quote:
Even Ctrl+F5 doesn't force it to download the markers.txt file again.

Ctrl-F5 will only force-reload the current request - ie: that script file.
It's unlikely that GDownloadUrl will pass through the no-cache header.


quote:
I added a "?" here:
Which did nothing.

Not surprising; nothing has changed.
The question mark just delimits the query string from the start of the URL.

You could probably add an actual query string onto the end, but you'd need to generate a random number, and I think that's a messy solution anyway.

Instead, I'd opt for switching your markers.txt to a markers.php and sending a no-cache header with that.
Here's some code from the PHP manual that should work:
PHP code:
<?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
?>


(you'd then have the txt content after that, and would possibly need to be slightly smarter about how you store the data)
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
33956.3 In reply to 33956.2 
I shall try what you've said tomorrow, when I'm also more awake. Spent ages tonight just trying to find a piece of free GPS software for my old smartphone and some for my Vario II that will just give me a nice and simple decimal read out of my current GPS location.

0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
33956.4 In reply to 33956.2 
Actually, I did it just now, and it works great.

Also:

quote: BP
(you'd then have the txt content after that, and would possibly need to be slightly smarter about how you store the data)


Explain! The data set works fine with just the PHP header at the top.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.5 In reply to 33956.3 
I've got GPS Utilities, which can export to NMEA, and that can then be converted with GPS Babel into something useful.


Babel is free, but Utilities requires a five digit code which may or may not coincide with the phone code for Hemel Hempstead.
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.6 In reply to 33956.4 
Wasn't sure how you're storing the data.
eg: If there was some script which dumped it then you'd need to prefix the PHP stuff at the top of that output.
If you're just appending to the end of the file then it'd be fine.
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
33956.7 In reply to 33956.6 

:D I'll get downloading that.

 

Yeah, I've just made a small PHP form where I just enter both co-ordinates, the data for the list on the right, and the data that goes in the marker bubble, and that gets put at the end of the file to extend the list of markers.


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.8 In reply to 33956.7 
I did have the occasional problem of the software deciding not to respond and needing to reset the device to get control back. Didn't lose position data though (once I stayed still whilst resetting/restarting).
That was with an older version (1.2.7 vs 2.0) and I was using it all day long. Hopefully the newer version is more stable.


Ah, and I just saw this:
quote:
In order to register the program, the owner name on your Smartphone/Pocket PC must match exactly with the one you provided at purchase.

Um... well you know my name. I suspect you only need to change it temporarily whilst registering, before being able to put it back again.


Anyway, I'm going to give in and let my brain have some rest now. Goodnight.
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
33956.9 In reply to 33956.8 
It didn't warn me of any trial period or needing to be registered when I installed it and ran it. It got all my GPS stats nice and easy. Looks like quite a good app if you don't need/want something like TomTom.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.10 In reply to 33956.9 
Check the About page.
It starts as a short full-version trial before for a couple of days, before falling back to a limited version (something like 10 minutes of logging at a time).
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
33956.11 In reply to 33956.10 
Ten mins of logging is about 9 minutes 59 seconds more than I need! I'll pretty much just be checking where I am, writing down the coords and posting them to my marker list.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
33956.12 In reply to 33956.11 
Ah, I thought you were doing a continuous tracking thing. Fair enough then. :)
0/0
 Reply   Quote More 

 From:  Serg (NUKKLEAR)  
 To:  ANT_THOMAS     
33956.13 In reply to 33956.1 
Mmm... I'd be quite interested in what you're doing and how - reason being that we've got a couple of groups (at work) who are going to do the Oxfam Trailwalker thing in July, and a real-time Google Maps toy might be quite a cool thing to have. It'd also give a post-walk view of what happened.

edit: even better, it'd be cool to have something like that for when Elena & I go driving around Europe in late summer, or for any other trips (or even if it can just log times & positions, and we'd upload the data afterwards instead of real-time).
[...Insert Brain Here...]
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Serg (NUKKLEAR)     
33956.14 In reply to 33956.13 
What do you want to know?

The markers on the map are made using the script that I posted above.

It quite simple drags the data from a text file (which is now a php file to sort the caching issue). The text file's important lines of code look like this

code:
51.128217|1.337110|26/01/2008 - 21:49<br /><img style="width:300px; height:202px" src="boat.jpg" />|26/01/2008 - 21:49
50.965761|1.857024|26/01/2008 - 22:09|26/01/2008 - 22:09
51.025710|2.353960|26/01/2008 - 22:30|26/01/2008 - 22:30
50.636200|3.050380|26/01/2008 - 22:59|26/01/2008 - 22:59
50.842330|4.351970|26/01/2008 - 23:13|26/01/2008 - 23:13


Each bit is separated by the "|" first two are the co-ords, next is the data that appears in the marker, and after that is the data that appears in the list on the right.

To get the co-ords I just use my PDA and a GPS dongle thing and will just write down the points and date and time. Then I have a small PHP form online that I just pop the data into the relevant fields and it is added to the list of markers. You could obviously have date and time be done automatically by the form, but I'm guessing I won't be doing every single point exactly when I'm there so if I have a list I can just input them whenever I get the chance.

Data costs for my mobile will be the thing that will stop me the most from doing it there and then.

0/0
 Reply   Quote More 

 From:  Serg (NUKKLEAR)  
 To:  ANT_THOMAS     
33956.15 In reply to 33956.14 
Oh, cool. Easy then :D *favouritiZes thread*
[...Insert Brain Here...]
0/0
 Reply   Quote More 

Reply to All    
 

1–15

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats