From: Mitch S. <mit...@be...> - 2009-11-20 06:51:17
|
Martin A. Hansen wrote: > I am wondering why Jbrowse files like refSeqs.js and trackInfo.js are > not in JSON format, but rather have a variable name, an equal sign, > and then, on the following lines, a block of JSON code: > > refSeqs = > [ > { > "length" : 50001, > "name" : "ctgA", > "seqDir" : "data/seq/ctgA", > "seqChunkSize" : 20000, > "end" : 50001, > "start" : 0 > } > ] > > Why not encode the entire thing in JSON? It's because of the caching behavior of XMLHTTPRequest in (at least some versions of) IE. For files that the browser knows about directly (files that show up in <script> elements in the HTML), the browser will check if they've changed when the user refreshes the page. But in IE, files that were fetched using XMLHTTPRequest always come from the cache (unless you add a query parameter that changes with each request so that the file never comes from the cache). I wanted the client fetch the file if (and only if) it had changed, so I figured I'd add an assignment line like the one above and put the file in a <script> element rather than getting it via XHR. Also, getting the refseq and track list information using a <script> element means that the data will already have been fetched when the embedder calls the Browser constructor. On the other hand, you could argue that that constructor should just be getting URLs and doing its own fetching, if (say) we wanted to refresh the track list without refreshing the page. As you've noticed, the track data and name tree files are just straight JSON, and those are fetched with XHR, so I guess there's a chance of IE getting stale data if one of those files has changed. Googling just now, it looks like there may be some nicer workarounds for this IE bug: http://en.wikibooks.org/wiki/JavaScript/XMLHttpRequest#Caching so changing this in JBrowse is probably something we should do at some point. Mitch |