mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Improve browser cache behavior with tiles (cache more often)
This commit is contained in:
parent
bb40f9b281
commit
a9b9a7c5c6
@ -69,7 +69,7 @@ var DynmapTileLayer = L.TileLayer.extend({
|
|||||||
var tileName = this.getTileName(tilePoint, zoom);
|
var tileName = this.getTileName(tilePoint, zoom);
|
||||||
var url = this._cachedTileUrls[tileName];
|
var url = this._cachedTileUrls[tileName];
|
||||||
if (!url) {
|
if (!url) {
|
||||||
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName) + '?' + new Date().getUTCMilliseconds();
|
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName);
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
@ -413,6 +413,11 @@ DynMap.prototype = {
|
|||||||
|
|
||||||
var prevworld = me.world;
|
var prevworld = me.world;
|
||||||
|
|
||||||
|
if(worldChanged) { // World changed - purge URL cache (tile updates unreported for other worlds)
|
||||||
|
me.registeredTiles = [];
|
||||||
|
me.inittime = new Date().getTime();
|
||||||
|
}
|
||||||
|
|
||||||
if(worldChanged && me.world) {
|
if(worldChanged && me.world) {
|
||||||
me.world.lastcenter = me.maptype.getProjection().fromLatLngToLocation(me.map.getCenter(), 64);
|
me.world.lastcenter = me.maptype.getProjection().fromLatLngToLocation(me.map.getCenter(), 64);
|
||||||
}
|
}
|
||||||
@ -623,30 +628,16 @@ DynMap.prototype = {
|
|||||||
var me = this;
|
var me = this;
|
||||||
var tile = me.registeredTiles[tileName];
|
var tile = me.registeredTiles[tileName];
|
||||||
|
|
||||||
if(tile) {
|
if(tile == null) {
|
||||||
return me.options.tileUrl + me.world.name + '/' + tileName + '?' + tile.lastseen;
|
tile = this.registeredTiles[tileName] = me.options.tileUrl + me.world.name + '/' + tileName + '?' + me.inittime;
|
||||||
} else {
|
|
||||||
return me.options.tileUrl + me.world.name + '/' + tileName + '?' + me.inittime; /* Browser cache fix on reload */
|
|
||||||
}
|
}
|
||||||
},
|
return tile;
|
||||||
registerTile: function(mapType, tileName, tile) {
|
|
||||||
this.registeredTiles[tileName] = {
|
|
||||||
tileElement: tile,
|
|
||||||
mapType: mapType,
|
|
||||||
lastseen: '0'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
unregisterTile: function(mapType, tileName) {
|
|
||||||
delete this.registeredTiles[tileName];
|
|
||||||
},
|
},
|
||||||
onTileUpdated: function(tileName,timestamp) {
|
onTileUpdated: function(tileName,timestamp) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var tile = this.registeredTiles[tileName];
|
|
||||||
|
|
||||||
if (tile) {
|
this.registeredTiles[tileName] = me.options.tileUrl + me.world.name + '/' + tileName + '?' + timestamp;
|
||||||
tile.lastseen = timestamp;
|
|
||||||
tile.mapType.onTileUpdated(tile.tileElement, tileName);
|
|
||||||
}
|
|
||||||
me.maptype.updateNamedTile(tileName);
|
me.maptype.updateNamedTile(tileName);
|
||||||
},
|
},
|
||||||
addPlayer: function(update) {
|
addPlayer: function(update) {
|
||||||
|
Loading…
Reference in New Issue
Block a user