ArcGISMapImageLayer RefreshInterval not working in some configurations

1308
7
02-06-2019 05:37 AM
BjørnarSundsbø1
Occasional Contributor II

Hi,

We are loading WebMap from portal, where RefreshInterval for some layers have been set. Using fiddler, I can see that new export requests are performed for the layer at the set interval on my development environment. Using the same version of the software against a WebMap in customer environment does not refresh. Using fiddler for verification, no new export requests are sent in customer environment, but they are sent on development machine.

Using Snoop to inspect the ArcGISMapImageLayer,RefreshInterval I can see it is set to 00:00:12 in both environments. Comparing the json for the WebMap and layer, they are the same, except for some field names matching, min scale and full extent. Enabling supportedExtensions KmlServer was the last idea based on where they differ, but this had no effect. We have also tried setting refresh to other layers, just to see if that causes different behavior. Clearing Internet Explorer cache between every change.

The only difference I can see now in export requests, is that on the computer where refresh works, both refresh requests (MapServer/export?dpi=96....and so on) and those related to navigation contain the extra parameters in the query string i.e:

_ts=1549457143832

layers=show:0

On the client where refresh doesn't work, these parameters are not present in normal export requests. I assume _ts is to avoid picking up images from IE cache with different URL for each request. layers I can't see should make any difference, from what I can read from Export Map—ArcGIS REST API: Services Directory | ArcGIS for Developers , and all the layers are displayed in the map when I see exported images.

Using ArcGIS Runtime for .NET 100.4, and ArcGIS Server 10.6 (and same version of portal). 

Sample information about operational layers from customer

"id": "pov_tet_5470",
"layerType": "ArcGISMapServiceLayer",
"url": "https://serverurl.com/agskart/rest/services/Product/pov_tet/MapServer",
"visibility": true,
"opacity": 1,
"title": "Layer name",
"itemId": "5e6b8ff78c68489b84f7b29d6809488b",
"refreshInterval": 0.2,
"layers": [
	{
		"id": 0,
		"popupInfo" : {}
	}
	

		‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Information about the same layer in development

"id": "rad_7401",
"layerType": "ArcGISMapServiceLayer",
"url": "https://serverurl.com/arcgis/rest/services/radioresources/MapServer",
"visibility": true,
"opacity": 1,
"title": "layer name",
"itemId": "2698b76d9b8146628ab88b051e678f12",
"refreshInterval": 0.2,
"layers": [
	{
		"id": 0,
		"popupInfo" : {}
	}‍‍‍‍‍‍‍‍‍‍‍‍‍

Does anyone have any idea on why it works in one environment, and not in another?

0 Kudos
7 Replies
BjørnarSundsbø1
Occasional Contributor II

This is extremely strange. Yesterday I was able to create a quick sample from XAML with one ArcGISTiledLayer and ArcGISMapImageLayer (with RefreshInterval) where the refresh worked. Today I am not able to do so, and the layer never refreshes (by checking Fiddler). Creating the map from code doesn't work either. Is there something obvious related to auto refreshing layers that I have completely missed, or is the functionality unstable?

0 Kudos
dotMorten_esri
Esri Notable Contributor

Could it be that the server in production is sending a cache control header, telling the client that it should cache the response, and not bother requesting again?

0 Kudos
dotMorten_esri
Esri Notable Contributor

...also try and listen to this event and see if that is hit every time it's supposed to refresh: Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler.HttpRequestBegin


If this event is hit, it's most likely because the http cache is kicking in and using a cached version just like the server instructed it to do.

0 Kudos
BjørnarSundsbø1
Occasional Contributor II

I tried listening to the event, and it does appear to use from cache. The _ts parameter is not set, which I assume results in the cache being used, just as in production.

I can recreate the same situation with the following map. No _ts parameter is added to the request, and apparently the result is returned from cache every 6 second, which makes sense based on my initial post, in relation to your reply. This appears to be the same behavior I see from the production environment.  This is a very simple sample using ArcGIS online services, which I have no control over. I would have expected refresh interval to work out of the box

        <esri:MapView x:Name="MyMapView" Background="Transparent">
            <esri:Map>                
                <esri:ArcGISTiledLayer Source="https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
                <esri:ArcGISMapImageLayer Source="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer" RefreshInterval="00:00:06"/>
            </esri:Map>
        </esri:MapView>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In the initial request to GET /ArcGIS/rest/services/Earthquakes/Since_1970/MapServer?f=json, there is no details in regards to headers that I can see.

What kind of changes would I have to do to avoid sending cache control headers, and change the behavior of my servers?

0 Kudos
dotMorten_esri
Esri Notable Contributor

I'm not expert on the server configuration bit, so asked around and got this:

> Please see section “Defining the value of the cacheControlMaxAge property“

> https://enterprise.arcgis.com/en/server/latest/publish-services/linux/map-cache-usage-by-clients.htm

0 Kudos
BjørnarSundsbø1
Occasional Contributor II

Thanks. I will ask the server administrators to take a look at this for the services that should have refresh interval. While this will hopefully help, it doesn't explain why in one scenario my client adds the timestamp (_ts) to the request to avoid caching issues, while in production and the sample XAML it does not.

Sorry if I'm being pushy  My assumption was that when using RefreshInterval, _ts would automatically have been appended to avoid cache issues. Perhaps this is yet another example that one should not assume  The funny thing is that when loading from portal in development environment, _ts is appended and refreshing work (it didn't a couple of weeks ago). Pointing directly to the rest endpoint of the service, rather than through portal item, the refresh does not occur and no _ts is appended to the request. Based on your previous post, I'll not ask more related to making servers behave 

0 Kudos
BjørnarSundsbø1
Occasional Contributor II

Today I'm having a rather absurd experience; the layer that yesterday worked with refresh and sent _ts parameter in the query string no longer works. No _ts in query string, and the requests are returned from cache. There have been no changes to anything on the client or the server side. The only change is that my laptop was turned off during the night, and the date has changed.  I think I will be as blunt as to claim there is a bug with the refresh functionality of this layer, as well as feature service layer.

We have also tried changing cacheControlMaxAge from the description at Map cache usage by clients—Documentation | ArcGIS Enterprise. While I can see in the header from fiddler that Cache-Control: private, max-age=0 has been changed. If I change it to 1 second in the properties, max-age=1. However, this does not affect the behavior of the refresh.

While not optimal, using ArcGISHttpClientHandler.HttpRequestBegin Event  to append _ts=<unixtimestamp> to export requests missing this parameter is a feasible workaround in a crisis. That allows the request to go to the server and not fetch from cache. The downside is that all export operations will be affected by this, and knowledge about RefreshInterval to layers is not available where I need to place my handler (object life cycle, static event handler, phobia of memory leaks, etc), but it will do the trick until the root cause is identified and resolved.

0 Kudos