Automating cache creation and updates with geoprocessing

If you're working with a basemap that is unlikely to change, chances are you'll create its cache only once. You can launch ArcGIS geoprocessing tools to create the cache and add tiles to it. This is also an appropriate way to update the cache if your data does not change very often.

If your data changes often, you still might be able to use caching. The caching tools have been designed to allow you to script cache updates and target specific parts of the cache for updates. For example, you can do the following:

The way to automate the caching process is to write scripts that use tools from the Caching toolset in the Server Tools toolbox. This toolset contains tools for both map caching and globe caching.

To create a new map or image service cache, you will typically start with Create Map Server Cache tool, which initializes the cache. Then you run Manage Map Server Cache Tiles to add tiles to the cache.

To build a globe service cache, you just need to run the Manage Globe Server Cache Tiles tool. By nature, all globe services have a cache that is automatically created when you start the service. This cache uses a built-in tiling scheme that is the same for all globe services. Therefore, there are no tools for creating a new globe cache or tiling scheme.

There are many tools that work with exporting, importing, and deleting caches. For a summary of all available tools, see An overview of the Caching toolset.

Using the tools in scripts

Although you can manually open the caching tools from the Catalog or Search window, it's more efficient to create a model in ModelBuilder or write a geoprocessing script that contains one or more tools that you want to run. You can then schedule scripts to run automatically.

The geoprocessing tool reference topic contains a full Python code sample showing how to use the tool in a script. For example, see the help for Manage Map Server Cache Tiles.

If you're new to Python, these resources can help you learn more:

Scheduling your script to run on a regular basis

You can save your script as a Python script file (.py). Double-clicking the script in Windows Explorer will cause the script to run. This is useful for testing, but in most cases, you'll want to schedule the script to run automatically on a regular basis.

Your operating system contains utilities that help you schedule tasks such as running a script. In Windows you can use Task Scheduler or the schtasks command. You'll need to provide the location of the script file, how often you want it to run, and the name and password that the task will run as. For further reading, see Scheduling a Python script to run at prescribed times.

Using your models with 10.1 Service Pack 1.

If you've created a model that uses the Export Map Server Cache or Import Map Server Cache tools and you apply 10.1 Service Pack 1, you must do the following to ensure your model recognizes the updated parameters for these tools:

  1. In the Catalog window of ArcMap, browse to the location of your model.
  2. Right-click your model and click Edit.
  3. Click Model > Validate Entire Model.
  4. Click Model > Save.