FeatureLayer Refresh in v4.9

2821
9
10-31-2018 08:22 AM
RavinderBhatia
New Contributor II

Hi,

I am trying to refresh the FearureLayer and it is not working and on top of that it is heavily cached as the FeatureLayer data is updated every 2-3 minutes but it's not reflecting back in the browser when we refresh it.

Can you guys let me know how can I achieve the "cacheBust: true" in the esriRequest? I am not able to achieve it from the following documentatin

request | API Reference | ArcGIS API for JavaScript 4.9 

Thank you.

0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Emeritus

Ravinder,

   FeatureLayer refreshinterval is broken in 4.9 it will be fixed in 4.10.

https://community.esri.com/thread/222899-featurelayer-refreshinterval-is-broken-in-49#comment-807136 

RavinderBhatia
New Contributor II

Hi Robert,

Feature layer refresh interval is working fine now after we changed to v4.10.

There is one more issue we are having, the response for each refresh is status 304 and data is all cached. 

We are updating the data using FeatureServer/addFeatures API Post call. When we do a FeatureLayer query call we can see the updated data but not when the layer is refreshed.

In older version 3.23 we fixed the caching issue from the link below by using "preventCache = true"

https://community.esri.com/thread/49024 

Is there a way to prevent caching in 4.10?

Thank you!!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I have not looked into that. I would guess that you could use esriConfig.request.interceptors to fix that:

https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request 

JohnGrayson
Esri Regular Contributor

Does it update when you call FeatureLayer.applyEdits(..) instead?  Maybe using the 'cacheBust' parameter in a RequestInterceptor might help?

RavinderBhatia
New Contributor II

Thank you Robert and John!


I have not tried either options, I will try and see if that helps.


Cheers!

0 Kudos
Jay_Gregory
Occasional Contributor III

I was still seeing this issue in 4.10 with a refresh interval on a feature layer and unique value rendererer.  The layer wasn't updating correctly until I added a request interceptor

esriConfig.request.interceptors.push({
before: function (params){
params.requestOptions.cacheBust = true
}
});
RavinderBhatia
New Contributor II

Thanks Jay! I'm still having the same issue, I think it only adds a "preventCache=someRandomNumber" to one of the first requests but not the layer refresh interval which I'm trying every 10 seconds. 

0 Kudos
MatthieuThery1
Occasional Contributor

Still not working for me. I have a Feature Layer with a UniqueValueRenderer, tried featurelayer.refresh() or the refresh interval, tried the request interceptor above, not working. I still have to manually zoom in and out for the layer to refresh.

RavinderBhatia
New Contributor II

I have tried Jay's suggestion params.requestOptions.cacheBust = true but it is not working for me either.

0 Kudos