Cache-buster + remove diagnostic logs
User's browser showed 404 and CORS errors for Carto tiles even though curl shows the URLs return 200 with CORS headers. Most likely the browser had cached earlier failed attempts. Added a per-tile cache-buster (?v=Date.now()+random) to the fetch URL so every tile request bypasses the browser's HTTP cache. Removed the diagnostic console.log lines since the issue is identified (browser cache).
This commit is contained in:
1 parent
7c7c882aa1
commit
83fd829cd5
1 file changed
+6
-5
Vendored
+6
-5
@@ -318,8 +318,11 @@ function fetchTileImage(tileX, tileY) {
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.onload = function() { resolve(img); };
|
||||
img.onerror = function() { reject(new Error('tile fetch failed')); };
|
||||
// Carto/OSM-style format: {z}/{x}/{y}.png
|
||||
img.src = GROUND_TILE_URL + GROUND_TILE_Z + '/' + tileX + '/' + tileY;
|
||||
// Carto/OSM-style format: {z}/{x}/{y}.png with a per-tile cache
|
||||
// buster to avoid any browser-cached 404s or CORS rejections
|
||||
// from previous failed loads.
|
||||
img.src = GROUND_TILE_URL + GROUND_TILE_Z + '/' + tileX + '/' + tileY
|
||||
+ '?v=' + Date.now() + '_' + Math.floor(Math.random() * 1e6);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -397,8 +400,7 @@ function drawTileAt(lng, perp, dx, dz, centerTileX, centerTileY) {
|
||||
mirrorLabel('x=' + tileX, canvasX + GROUND_TILE_SIZE - 12, canvasY + GROUND_TILE_SIZE - 12, 'left');
|
||||
|
||||
return true;
|
||||
}).catch(function(err) {
|
||||
console.warn('[clouds3d] tile fetch failed', tileX, tileY, err && err.message);
|
||||
}).catch(function() {
|
||||
// On failure draw a neutral gray so the gap is at least
|
||||
// not the bright fog colour
|
||||
groundCtx.fillStyle = '#3a4458';
|
||||
@@ -450,7 +452,6 @@ function rebuildGroundMosaic(centerTileX, centerTileY) {
|
||||
// smooth parallax within the loaded content.
|
||||
function refreshGroundMosaic() {
|
||||
if (!groundCtx) return;
|
||||
console.log('[clouds3d] refreshGroundMosaic center', groundCenterTile);
|
||||
var fdx = (window.__flightDir && window.__flightDir.dx) || 0;
|
||||
var fdz = (window.__flightDir && window.__flightDir.dz) || 1;
|
||||
var camX = (fdx !== 0) ? groundCameraX * fdx : 0;
|
||||
|
||||
Reference in new issue
Block a user