Skip To Content

Map cache usage by clients

When working with map caches in different clients (either web or desktop based), you need to consider how the application works with the tiles, whether it stores tiles locally, and what conditions it requires for cache overlays.

How applications access and use the cache

Once you define a tiling scheme for your map service, the service immediately begins trying to use the cache. Any ArcGIS application that can display a map service uses the cache, although how the tiles are retrieved and used varies between applications.

Web applications

When developing with the ArcGIS API for JavaScript, you use a specific class to specify that you're connecting to a tiled (cached) map service. For example, you use ArcGISTiledMapServiceLayer to connect to a cached service. When you use the cached service, tiles are retrieved from the cache directory by REST calls to the map service. The tile request takes the form http://<map service URL>/tile/<level>/<row>/<column>.

If you are viewing a single cached service in any web application and pan to an area where tiles do not exist, the application does not display a dynamic image; instead, you don't see anything. One way to ensure that you see a map when you pan to an uncached area is to enable on-demand caching.

Tip:

If the map appears more slowly than expected, examine the URLs of the map images to verify that the application is retrieving tiles. One way to do this is to open the application in Mozilla Firefox and click Firefox > Web Developer > Web Console. When the console appears, click the Net button and zoom or pan your map.

  • If you see URLs like this, your application is successfully getting tiles from REST requests:

    http://gisserver.domain.com:6080/arcgis/rest/services/myService/MapServer/tile/10/1723/3495.jpg

  • If you see some other URL format for your map images, your application is retrieving the tile in a less efficient way or the cache is not being used.

ArcMap and ArcGIS Pro

You add cached map services to ArcMap and ArcGIS Pro using the Add Data button, the same way you add any other map service. There are two ways you can view a cache:

  • Access the cache through a map service—To view a cache this way, browse to the GIS server and the map service used to create the cache. In this scenario, an initial connection to the GIS server is made to determine if the service has a cache. Then the tiles are retrieved from the cache directory on the server's file system.
  • Access the cache as a raster dataset—To view a cache this way, browse to the directory containing the cache tiles and add the dataset. The cache is represented with the same icon used to add all other rasters using the Add Data button. A cache accessed as a raster is for viewing only and cannot be queried. The advantage with this type of cache is that it is not tied to a map service and can be viewed when disconnected from the server, as long as you can still access the cache directory.

When a request is made for a tile at a scale that exactly matches a scale level in the cache, the map service returns the tile directly. Most often, requests do not exactly match the scale levels in the cache. In this situation, the tile from the next closest scale level is requested and resamples it to match the requested scale. This resampling is still much quicker than generating a tile dynamically; however, it does result in an image that looks different than the original tile. Map labels that have been cached may be difficult to read at certain scales due to this resampling. For best results, view the map at or near the scales from which the cache was created.

ArcGlobe and ArcGIS Explorer

ArcGlobe and ArcGIS Explorer can read 2D caches and drape them over the surface of the globe. You'll get the best performance if you build the cache with the ArcGIS Online/Google Maps/Bing Maps tiling scheme. If you cannot use one of these tiling schemes, your best performance will come from using globe services.

One scenario where you may want to add a map service to ArcGlobe is when you've created a 2D map cache and want to create an identical 3D globe cache from the 2D cache. In this scenario, you would only be concerned with generating the cache and would not be navigating the globe.

Improving the display performance of cached map services

When clients send requests to ArcGIS Server to display a map service, the response from the server is typically cached by the browser and reused for a certain period of time. This behavior helps ArcGIS Server achieve the best possible display performance for your map service. However, depending on how your map service and its associated data are used in applications, you may consider adjusting the length of time the browser will use a response in its cache. This can be achieved by adding a property named cacheControlMaxAge to the JavaScript Object Notation (JSON) of the service.

How the cacheControlMaxAge property is used

ArcGIS Server map service responses include an entity tag (ETag) and Cache-Control header. The ETag header value is a unique identifier of the response. The Cache-Control header has a max-age value that provides information to the browser regarding the maximum time period for which it can reuse a response from the browser's cache. This value is controlled by the cacheControlMaxAge property.

When a request is repeated and the maximum age of the cache has not expired, the browser will use the cached response without sending the request to the server. If the maximum age has expired, the browser must send the request to the server and set an IF-NONE-MATCH header with an associated ETag value corresponding to the response in its cache. ArcGIS Server evaluates the request and uses the ETag value to determine if the response has changed. If the response from the server is different from the copy on the browser, the server will send a completely new response to the browser. If the response is identical to the copy on the browser, the server alerts the browser to continue to use the response in its cache.

Defining the value of the cacheControlMaxAge property

To specify how long a browser is allowed to use a cached response, define the cacheControlMaxAge property. This property can be set for individual service caches. By mitigating the need for ArcGIS Server to send a full response, you allow your browser caches to be more efficient, help optimize your applications, and save network bandwidth.

For cached map services that do not allow clients to cache tiles locally, the default is 0. This means the browser will always resend a request and ArcGIS Server will process the request and send a full response to the browser if the content has changed. This value works well for most applications.

For cached map services that allow clients to cache tiles locally, the default value is 86,400 seconds (1 day). This means that if a request is repeated within 1 day, the browser will use the response from its cache.

For cached map services where the map or data does not change frequently, it is recommended to increase the default to 30 days (259,2000 seconds) or longer to minimize network traffic.

To add the cacheControlMaxAge property to your service and specify its default value, do the following:

  1. In a web browser, open the ArcGIS Server Administrator Directory and log in with a user that has administrator privileges. The URL is formatted http://gisserver.domain.com:6080/arcgis/admin.
  2. Click services and select the map service you want to modify from the Services list. If you don't see your service listed, it may be in a directory under the Root folder.
  3. On the Service - <service name> (<service type>) page, scroll to the bottom and click edit.
  4. In the Service Properties dialog box, locate the properties section of the service JSON.
  5. Add the cacheControlMaxAge property to the section and specify the value (in seconds) for the property, for example:
    "properties": {
      "cacheControlMaxAge": "2592000",
  6. Click Save Edits.
  7. On the Service - <service name> (<service type>) page, verify that the cacheControlMaxAge property and the value you specified for it appears in the Properties section.

Overlaying caches

When designing map caches that will be overlaid with other map caches, applications require that you match coordinate system and tile size. It's also a good practice to match as many scales as possible.

The easiest way to do this is to match tiling schemes for both caches, then only create tiles at the scales that make sense for each cache. This way, you can be sure that you've matched coordinate system and tile size and that the software recognizes that the two caches have scales in common.

Force a dynamic draw

If you notice that your tiles are of poor quality due to resampling or you want to see dynamic data at certain scales, you can force the service to ignore the cache and draw the map dynamically. You can do this for specific levels in the map.

For example, imagine you want to show real time data at large scales. You have a map that is cached from zoom levels 0 – 15, but should be drawn dynamically from levels 16 – 19. The solution is to enable dynamic layers on levels 16 – 19 and specify in your map requests that you want to use dynamic layers at these levels. Otherwise, the service will return a map constructed from available tiles, which will be blank in areas where tiles don't exist.