cache hint > how does it work ?

840
3
12-02-2022 02:43 AM
MatthieuThery1
Occasional Contributor

Hello,

We are trying to replicate what's heppening with this layer for example: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-featurelayer

It seems it is building a client side cache that's being used instead of throwing queries every time. Our layer has "supportCacheHint" set to true, but it's still not working.

Is there something we need to do to enable this caching?

0 Kudos
3 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

The sample you referenced is not related to supportsCacheHint. At 4.19, we improved of performance of point FeatureLayers to fetch all its features at once from the server. Once loaded, the features won't need to be re-requested from the server, which will make future redraws after panning and zooming much faster.

Point feature layer fetches all of its features at once if the following conditions are met: 

  1. featureCount = 0-80,000, fetch all features  
  2. featureCount = 80,001-400,000, fetch all features if view's initial extent is greater than 10% of the layer's data extent (i.e., if we are not super zoomed)

The point feature layer will request features as needed (do not fetch all features) if 

1. Point layer is editable
2. If layer.refreshInterval is set and lastEditDate is `undefined` in the metadata.

The point layer referenced in the sample fetches all of features as once since it meets the requirements mentioned above. 

If you enabled caching on your enterprise service (caching always enabled for hosted feature services), the JS API will take advantage of the server caching as it makes tile query requests for display. Please review this document for more info about caching. 

If you are sending query requests from your app and the query params always the same you can set the cacheHint property on your query object. 

https://next.sites.afd.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#cache...

 

 

MatthieuThery1
Occasional Contributor

Thanks a lot for your answer.

Is there a plan to support caching for polylines/polygons Feature Layers (with a smaller feature count for example)?

0 Kudos
UndralBatsukh
Esri Regular Contributor

Yes we do have plans add support for fetching all polyline and polygon features at once if they meet certain requirements. However, I do not know what the timeline is. I will be sure to update you once we add support for this.

0 Kudos