The best way to create fast map services is to cache them. When you cache a map service, the server draws the map at a set of scale levels that you define and saves the images. When the server receives a request for a map, it's much quicker to return one of these cached images than to draw the map again.
Caching is appropriate for basemaps and maps that don't change often. For maps that change only occasionally, tools are available to update the cache. To achieve optimal performance, you should cache as many layers as you can. You may find it helpful to make two maps and separate the layers that are appropriate for caching from layers that would not be feasible to cache. For example, you could create a cached map service from the basemap layers and a non-cached map service from layers that get updated in real time or layers that change as a result of analysis or modeling.
Creating an effective map cache requires you to do some careful design and authoring work before you build the cache. This topic describes the process of planning and authoring a map that will be cached. You'll then publish a map service and specify when the cache should be built. Finally, you'll test the cache in a client application.
Before you begin
If you've just installed ArcGIS Server, you need to complete some preparatory steps before you can connect to the server in ArcMap and publish services:
- For details on how to configure your ArcGIS Server site, see Getting started after install.
- To learn how to make the data referenced by your GIS resource available to the server, see Making your data accessible to ArcGIS Server.
Author the map
When you cache a map, the server draws it at a set of scales that you select. Once the map is drawn, you can't change the way it looks unless you re-create or update the cache. This means two important things:
- The map needs to look good at each scale level before you cache it—A paper map is designed to look good at one scale, but a cached map has to be designed for every scale that you cache.
- The scale levels you choose are very important—If you pick too few scales, users may feel that they are missing information or cannot get a good view of the map. If you pick too many scales or pick scales that are unnecessary, you increase the cache creation time and required storage space. Conversely, your organization may have already determined a tiling scheme to use when caching. A tiling scheme determines certain properties of your cache, including which scale levels to create.
Specify the coordinate system
When designing this map, you'll need to set the data frame to use a specific coordinate system. This is the coordinate system that will be used to display your cache tiles.
- Start ArcMap and open a new empty map document.
- In the ArcMap table of contents, right-click the data frame name (the default is Layers) and choose Properties.
- Click the Coordinate System tab and select the coordinate system you want to use for your map.
- Click OK.
Design the map
Now it's time to do the real map design work. One benefit of caching your map is that during the design phase, you can use all the cartographic tools at your disposal without worrying about how they will affect performance. Take some time to make your map look nice, because once the cache is created, you will not be able to make changes without re-creating or updating the cache. Users of the cache won't be able to change the symbology either, since they're just viewing preexisting images of the map that are stored on the server.
A good practice is to design your map at each scale interval. This is easier for raster data because ArcMap does some resampling of the data as you change scales. Vector data, however, will be symbolized with the same size points and lines at each scale and requires a little more effort to keep the map from looking too cluttered or too sparse. The steps below describe a design strategy you can use if your map contains vector data.
- Remaining in ArcMap, add your datasets and zoom out to the farthest (smallest) scale. If necessary, correct any projection issues. All of your datasets need to use the same projection in order to be cached correctly.
- Set the symbology and labeling of your layers for this scale.
You may want to set a definition query so that fewer features are visible at this scale. For example, if you have a cities layer, you can set a definition query that limits display to cities with a population greater than 20,000.
- Zoom in to the next closest scale and set the symbology and labeling of your layers for this scale.
If you want to change the symbology, labeling, or definition query on a layer that you already symbolized at a different scale, add another copy of the layer to the map. To do this, right-click the layer in the ArcMap table of contents and click Copy. Then right-click the data frame name and click Paste Layer(s).
- Create group layers to keep track of the copies of your layers. It's easiest to make one group layer for each scale. That way, you only have to set the scale dependency on the group instead of on each individual layer. You might even include the scale in the name.
- Set a scale range on each group layer so that only one is visible at each cached scale. Configure the scale range with a tolerance around each cache scale. For example, if one of your group layers will be cached at 1:577,791, you might set the layer to be visible only when zoomed out beyond 1:866,686 and zoomed in beyond 1:433,343.
- Continue zooming to each successive scale and symbolizing appropriately until you've worked through all the scales in the scales list.
- Save your map. You're ready to publish the map.
Publish the map and create the cache
Publish your map document to ArcGIS Server using ArcMap. During this process, you will define the schema of your map cache and analyze your map document for performance. You'll also specify when you want to create the cache.
- Open your map document in ArcMap and choose File > Share As > Service from the main menu.
- In the Share as Service window, choose Publish a service. Click Next.
- In the Publish a Service dialog box, click Connect to ArcGIS Server to create a new connection to the server.
- In the Add ArcGIS Server window, choose Publish GIS Services. Click Next.
- For the Server URL, type the URL of the ArcGIS Server site you want to connect to. The URL will be in the format http://gisserver.domain.com:6080/arcgis.
- From the Server Type drop-down list, choose ArcGIS Server.
- Enter a User Name and Password with at least publisher privileges on ArcGIS Server. If you haven't set up users and roles for security, one option is to use the Primary Site Administrator account you defined when you created the site. Leave the checkbox checked to save the username and password. Then click Finish.
- Optionally, in the Publish a Service window, enter a new name for the service. Click Next.
- By default, services are published to the root folder (root) of ArcGIS Server. Services can be organized into subfolders under the root folder. Choose the folder where you want to publish the service, or create a new folder to contain the service. Click Continue.
- The Service Editor displays. You'll use the Service Editor to choose what users can do with your cached map service, define your caching schema, and take fine-grained control of how the server will expose your service. Click the Caching tab.
- In the Caching tab, choose to draw the map service Using tiles from a cache.
- In the Tiling Scheme drop-down list, choose the tiling scheme for your cache. The tiling scheme determines the scales at which tiles will be created and the boundaries of your tiles. It contains information about the coordinate system of the cache and some other properties. There are several ways to choose a tiling scheme:
- If you want to use the same tiling scheme as the ArcGIS Online, Bing Maps, and Google Maps caches, choose ArcGIS Online / Bing Maps / Google Maps. The data in your map will be reprojected on the fly to the required coordinate system of this tiling scheme, which is WGS 1984 Web Mercator (Auxiliary Sphere).
- If you want to use the same tiling scheme as the WGS84 Geographic, version 2 caches, choose A tiling scheme file and browse to C:\Program Files (x86)\ArcGIS\Desktop10.5\TilingSchemes\WGS84_Geographic_Coordinate_System_V2.xml. The data in your map will be reprojected on the fly to the required coordinate system of this tiling scheme, which is WGS 1984.
- If you want to use your own tiling scheme, choose A tiling scheme file and browse to a tiling scheme XML file that you have created using the Generate Map Server Cache Tiling Scheme tool.
- If you want to use the same tiling scheme as another existing map service, choose An existing cached map / image service and browse to the service.
- If you want ArcGIS to suggest some scales for you, click Suggest and type the number of scales you want. This option is only recommended for experimental or testing purposes. In most cases, you will have already designed your map with a specific set of scale levels in mind.
- Use the sliders to set the Levels of Detail property.
Tiling schemes often contain many scales. Depending on your map, you might want to forego caching some of the extremely large or small scales in your tiling scheme. ArcGIS examines the scale dependencies in your map and suggests a minimum and maximum range of scales for caching. You can adjust this range to your liking. The remaining scales are not removed from your tiling scheme, but you will not be able to create tiles for them unless you return to this dialog box and include them in the range.
- Choose whether the cache will be built automatically when the service is published, or whether you will build the cache manually after the service is published. These options are available at the bottom of the Service Editor.
Use the reported Estimated Cache Size and the more accurate accompanying utility Calculate Cache Size to help you make this choice (see Estimating the size of a map cache to learn more about these estimates). If the cache is large, it’s wise to build it manually in phases, caching the largest scales at selected areas of interest that are most likely to be visited. If the cache is small, it’s easier to just build the whole cache automatically at the time you publish.
- If you have chosen to create the cache automatically at the time you publish, click Advanced Settings in the left menu and choose the Area of interest to cache.
If the shape of the geography you are caching is not rectangular, it’s recommended you choose Import from a feature class and browse to a simple feature class containing your geography of interest. See Map caching based on feature boundaries for guidelines on preparing this feature class.
- Adjust other properties from the Advanced Settings tab as appropriate. These settings are described in Available map cache properties.
- Click Analyze . This examines your map document to see if it can be published to the server.
To give yourself more viewing area when configuring your map service, click the Collapse button at the top of the Service Editor.
- Fix any Errors in the Prepare window; this must be done before you can publish your map as a service. Optionally, you can fix the warnings and informational messages to further improve the performance and appearance of your service. For more information about resolving these issues, see Analyzing your GIS resource.
You can register folders and geodatabases with your ArcGIS Server site, thus ensuring that the server can recognize and use your data. If you proceed with the following steps, any data referenced by your map document originating from an unregistered folder or geodatabase will be copied to the server at the time that you publish. This is a precautionary measure to ensure that the server can access all the data used by the service. For full instructions on registering a folder or geodatabase with your ArcGIS Server site, see Registering your data with ArcGIS Server using ArcGIS Desktop.
- Optionally, in the Service Editor, click Preview . This can give you an idea of how your map will look when viewed on the web. See Previewing your map for more information.
- If you’re creating a new service, click Publish when you are ready to publish. If you’re editing an existing service, click OK to save your changes.
If you chose to build your cache automatically it will begin building at this time. You can check its progress by viewing the geoprocessing Results window in ArcMap. The cache is created asynchronously. This means you can close ArcMap while the caching is occurring.
- If you chose to build your cache manually, right-click your service in the Catalog window and click Manage Cache > Manage Tiles. This displays the Manage Map Server Cache Tiles tool, which you can run using the scales and areas of interest that you choose. You can perform asynchronous caching by unchecking the parameter Wait for job completion on the Manage Map Server Cache Tiles tool.
Test the cache
Once the cache is finished, you can test it in a web application to make sure that the map appears and performs the way you expect. This is also a good way to verify that the tiles are being recognized and used successfully by the application.
- In a web browser, navigate to the Services Directory. The URL will be in the format http://gisserver.domain.com:6080/arcgis/rest/services.
- In the services list, click your map service. All map services are appended with (MapServer). If your service resides in a folder, navigate to that folder and find the service.
- Pan around the map and zoom to the different levels. When panning and zooming in the map, you should see the map tiles appear very quickly.
If it doesn't appear that the application is using the cache, make sure that the ArcGIS Server account has read and write permissions to your server cache directory.
If you're using Mozilla Firefox to view your web application, there's an easy way to tell if your cache tiles are being used.
- Right-click inside the web application and choose View Page Info.
- In the Page Info window, click the Media button.
- Examine the images that appear in the list. If you see URLs referencing your server cache directory, you know your cache is being used.