When I edit the WebMap in my portal, such as adding new layers or configuring Popup, these changes are immediately available for my Web Application. However, when I load the map from the Runtime, the changes are not available when I restart my ArcGIS Runtime application.
It appears that when I clear my IE cache and all historic data, the changes to my Web Map are picked up when I restart the application. While I understand the benefit of caching information on the client, is it possible to disable this caching for metadata about a WebMap so I don't have to clear my cache whenever I make a change to my portal? Or at least make the caching have a shorter expiration?
Solved! Go to Solution.
The runtime uses the caching information the server relays. So if the server is saying "go ahead and cache this for a year", we won't requery for the next year. The server could also be using ETag caching, where we'd query back and say "hey, is this still the valid etag?" and the server could either respond with the a yes or return the new updated version with a new etag to use.
So if you're seeing issues here, it would be the server incorrectly reporting how to cache in its header. I suggest you use Fiddler (www.fiddlertool.com) to better understand what's going on.
The runtime uses the caching information the server relays. So if the server is saying "go ahead and cache this for a year", we won't requery for the next year. The server could also be using ETag caching, where we'd query back and say "hey, is this still the valid etag?" and the server could either respond with the a yes or return the new updated version with a new etag to use.
So if you're seeing issues here, it would be the server incorrectly reporting how to cache in its header. I suggest you use Fiddler (www.fiddlertool.com) to better understand what's going on.
Thank you for your answer.
I suspected it was header information from the response, and not on the request side. I started taking a look at fiddler yesterday, but at the time I couldn't find the request where the metadata is downloaded. As we've covered in the past, about the secret to infinite resources, I got stuck with something that had higher priority
For now I will settle with clearing the cache until I find more time to dig deeper.
It's a bit of a brute force approach but you could download the current WebMap definition through rest and then use the Map.FromJson to load it. That way you always load what is on the server.
Something along these lines would get you the WebMap definition
//_portal is a reference to the currently connected to portal
var handler = new ArcGISHttpClientHandler {ArcGISCredential = _portal.Credential};
string webMapJson;
//The portal item is retrieved from a bound list of 'listItem' type that has a property
// of type PortalItem for the selected list item
using (HttpClient portalClient = new HttpClient(handler))
{
//build the Url of the WebMap rest endpoint
Uri requestUri = new Uri($"{_portal.Uri.AbsoluteUri}/sharing//content/items/{listItem.PortalItem.ItemId}/data");
webMapJson = await portalClient.GetStringAsync(requestUri);
if ( string.IsNullOrEmpty(webMapJson) )
{
Log.Warn("Unable to retrieve WebMap data");
return;
}
}
From here you should be able to just do
var map = Map.FromJson(webMapJson)
That's what is happening under the covers, so the same caching issues would happen.
To work around it, you would have to make the Url unique, for instance by adding a timestamp:
new Uri($"{_portal.Uri.AbsoluteUri}/sharing//content/items/{listItem.PortalItem.ItemId}/data?t=" + DateTime.Now.Ticks.ToString());