Git Product home page Git Product logo

discussion's People

Contributors

kumavis avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

discussion's Issues

Offline and modifying xmlHttpRequest

Offline is important for a lot of our tools, and I've been experimenting with digidem/html5-image-cache caching images dynamically in local storage (although I recently found that a lot has already been done here and here)

For data that is dynamically loaded via xmlHttpRequest that is another challenge. To date I had approached it starting to write a custom Backbone sync adapter with js-git, but this is a complex approach. Importantly, what about external libraries that load data, like vector tiles in Mapbox-gl-js (a lightweight way to provide image tiles) or deforestation API data from CartoDB Torque?

For much of this data all we need is the ability to cache the data and potentially have the ability to "side-load" it via a USB rather than an internet connection.

My idea is to write a wrapper for XmlHttpRequest that works similarly to the image cache script: when called the first time it will save to a cache, when called a second time it will load from the cache. That way it could be transparent to any libraries like mapbox or cartodb that we use. We save all requests with a hash of the url, so we always get the same data at the same URL.

Both Mapbox-gl-js and torque use browserify, so we could write a transform to replace XmlHttpRequest with our own version, wrapping the original version and adding a caching layer.

We could also use this for our own apps, whether we use backbone or angular. We just agree that only read offline matters, then just use, for example, the standard Backbone.sync but cache at the XHR layer rather than the Backbone.sync layer.

To populate the cache, we would either need to visit everything with a connection, or call the relevant functions in each library to download the tile we want.

mbtiles would be a good format for side-loading. We would need to write a library to download the needed tiles and save to mbtiles, and have a standard way to encode the original urls into the mbtiles package. That way we could populate the cache of the webapp with the correct url-hashes as the ids, so that as far as the xmlHttpRequest wrapper is concerned, the cache has come from a previous request.

Thoughts on this? Task list:

  • wrapper to XmlHttpRequest that mimics the original functionality but adds a caching layer.
  • Browserify transform to replace XmlHttpRequest with our custom version
  • "downloaders" for whatever tools we use.
  • Library to "side-load" data from a file and populate teh XHR cache.

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.