misoproject / dataset

JavaScript library that makes managing the data behind client-side visualisations easy
http://misoproject.com
GNU General Public License v2.0
1.18k stars 99 forks source link

CSV data fails to update on page refresh in IE8 #195

Closed craig552uk closed 11 years ago

craig552uk commented 11 years ago

Using basic code like that below, updates to the csv data file are not reflected in the browser on a page refresh when using IE8.

  var ds = new Miso.Dataset({
    url: 'data.csv',
    delimiter: ','
  });
  ds.fetch({
    success : function(){
      this.each(function(row){
        console.log(row['field']);
      });
    }
  });

Steps to reproduce:

  1. Load page in IE8, note the field values.
  2. Edit the CSV file, changing some of the values.
  3. Refresh the page in IE8.
  4. Note that the data values have not changed.

The problem is not resolved with either a forced refresh or by clearing the browser cache.

Tested with IE8 on WinXP/Win7 Miso Version: miso.ds.deps.ie.min.0.4.0.js

alexgraul commented 11 years ago

This is odd but I'm not sure it's a dataset issue so much as an IE issue. Ie may however be related to jquery's caching options as per http://stackoverflow.com/questions/1013637/unexpected-caching-of-ajax-results-in-ie8 Can you try adding

$.ajaxSetup({
    cache: false
});

in your code before the dataset init and seeing if that helps?

craig552uk commented 11 years ago

Yes, I think it is a related problem. Though that fix didn't work, as dataset doesn't use jQuery.

As a work-around it's possible to append a random element to the request URL, which circumnavigates IE's aggressive caching.

var ds = new Miso.Dataset({
  url: function(){ return 'data.csv?'+ Math.random(); },
  delimiter: ','
});

I'll have a look at building a cache: false option in to dataset if that sounds acceptable?

alexgraul commented 11 years ago

That's a good point, been a while since I've worked on this! Sounds like a plan to me, will look forward to a pull request!

iros commented 11 years ago

Documented on the wiki under the "How Do I..." page.

Thanks, @iros.