CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.03k stars 3.51k forks source link

`compositeIndex` query parameter hurts browser cache performance for external resources. #10875

Open ptrgags opened 2 years ago

ptrgags commented 2 years ago

In #10524, I had added a compositeIndex query parameter to URLs to fix a bug with .cmpt tiles where some of the resources in the ResourceCache were being shared when they shouldn't be, leading to duplicate geometry rendering.

However, this forum post shows the one downside to this approach. By adding a query parameter, now each network request to a shared resource is treated as distinct, and therefore the browser won't be able to cache the results correctly.

I'm not sure what the best fix is here, some thoughts:

lilleyse commented 2 years ago

You should be able to use a fragment instead of a query parameter since the fragment doesn't get sent to the server. From https://www.webdevsplanet.com/post/url-parameters-vs-fragments:

The fragment identifier is only used by the browser and not sent in the HTTP requests to the server. You cannot collect or see them in your server-side code.

ptrgags commented 2 years ago

@lilleyse Hm it's definitely a thought. However,

  1. From the page you linked, it mentions that you can only have a single fragment. Probably okay in this unusual case.
  2. This would require modifying Resource, I see a couple places in the code there where it explicitly sets the fragment to empty string... was there a reason for this?

If the fragment option doesn't pan out, what if there was a resource.extras dictionary to store this information separate from the URL itself, but ResourceCacheKey functions could still access it if present?

lilleyse commented 2 years ago

Ah this will be trickier if going through the Resource class...

ufolr commented 1 year ago

any news of this issue?

ggetz commented 1 year ago

@ufolr There hasn't been any activity on this item recently.

If you'd like to add more information about your use case, that may help us prioritize.

If you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR.

Thanks!

ufolr commented 1 year ago

@ggetz I have some 3dtiles data with hundreds tree instance witch are same model, so I make the model gltf out of cmpt file, and hope cesium can render trees with Instancing. As expected I can get higher performance, but it's very slow because this same issue.

my problem is same like this: this forum post

I'm searching is there any way to fix or bypass this issue?