Database : IOfflineProvider - .manifest URL creation

Shouldn’t the .manifest URL creation be optimized?

Currently, this is the line that add the URL to get the .manifest file:

var manifestURL = this._currentSceneUrl + ".manifest";

That code leads to a problem when the asset is behind a protected API, or that some parameters need to be added to the requested (Azure Storage, Google Buckets, etc…).

I’ve made this simple playground just to illustrate:

This is the URL from the asset:

https://playground.babylonjs.com/scenes/skull.babylon?test=1

II’ve added a query string that makes no difference to the request. Though, it concerns the URL trying to get the .manifest file:

https://playground.babylonjs.com/scenes/skull.babylon?test=1.manifest&1613477087021

In any case, it should be:

https://playground.babylonjs.com/scenes/skull.babylon.manifest?test=1&1613477087021

A simple solution would be

const manifestURL = new URL(this._currentSceneUrl)
manifestURL.pathname += '.manifest';

var xhr = new WebRequest();

if (navigator.onLine) {
	// Adding a timestamp to by-pass browsers' cache
	timeStampUsed = true;
	manifestURL.search += (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
}

For the timestamp, another approach would be leveraging the use of URLSearchParams:

url.searchParams.append('t', Date.now()); // result t={timestamp}

Result:

https://playground.babylonjs.com/scenes/skull.babylon.manifest?test=1&t=1613477087021

Moreover, I am aware that a custom cache could be created on my own through IOfflineProvider. Though, I think that is a simple solution.

Adding @Deltakosh and @RaananW who may know what a “manifest” is (as I don’t :slight_smile: ).

@Evgeni_Popov Optimizing Using Cached Resources | Babylon.js Documentation

Sure, that makes sense to me.

Want to submit a PR to fix this? I also agree with the timestamp approach because the manifest should not be cached (unless configured like that on your server).
About URL - AFAIK IE11 does not support the URL class, and we therefore are prevented from using it. If you find an all-inclusive way of approaching this, it would be wonderful :slight_smile: . If you don’t feel like submitting a PR, you can create an issue on github, we will take care of this till the next major release.

Sure, I can take care of that. Also, I’ll look out about the IE11.

1 Like