It takes a lot of time to cache map tiles. See if we can either get them all before Twisted starts, or else use Twisted deferred HTTP gets to cache them asynchronously once Twisted starts. Of course, this would require figuring out all the tiles we need...
One option would be to simplify how they're cached, and instead of using the API endpoint like we do now, see if we can do something lazythumbs-style... i.e. have the map tile endpoint try to serve from disk with a Twisted File(), and if the file isn't available (404... exception...) then catch that, fetch the tile and save it to disk, and serve it. This would mean changing the tiles API path to match how GW2 does it.
The tile service API docs provide some insights into how we can determine which tiles are available; specifically, "Valid continents and floors can be obtained using the continents resource. The map_floor resource contains useful information like the size of each floor, and bounding rects. The bounding rects define which tiles are available for download, as well as the area of the map that should be presented to the user." We'd probably want to limit which tiles we pre-cache to the actual world map zones.
One option would be to do this before Twisted starts, either just synchronously or use some sort of asynchronous queue to download them as fast as possible (maybe we'd use Twisted for this... build the queue, start the reactor, then stop the reactor when the queue is empty and clear out any state?)
Another option would be to just run this with Twisted, and have it start once the reactor starts... and either just assume that tile loading will be slow on the first program run, or else have it set some API-based flag that the JS can look for, to have the UI block until tile loading is done.
It takes a lot of time to cache map tiles. See if we can either get them all before Twisted starts, or else use Twisted deferred HTTP gets to cache them asynchronously once Twisted starts. Of course, this would require figuring out all the tiles we need...
Google Maps API article about tiles
Possiblilities:
File()
, and if the file isn't available (404... exception...) then catch that, fetch the tile and save it to disk, and serve it. This would mean changing the tiles API path to match how GW2 does it.