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 display performance for your map service. However, depending on how your map service and its associated data are used in applications, you can adjust the length of time the browser uses a response in its cache. This is done by adding the cacheControlMaxAge property 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 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 uses 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 than the copy on the browser, the server sends a 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.
Define the value of the cacheControlMaxAge property
As an ArcGIS Server administrator, you can define the cacheControlMaxAge property to specify how long a browser is allowed to use a cached response. By mitigating the need for ArcGIS Server to send a full response, your browser caches are more efficient, help optimize your applications, and save network bandwidth.
The default value for map services 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 map services with frequently changing datasets or symbology, a value such as 5 minutes (300 seconds) is recommended. In applications with animations or time-aware data, consider increasing the value to give your application a smoother animation experience.
To add the cacheControlMaxAge property to your service and specify its default value, do the following:
- In a web browser, open the ArcGIS Server Administrator Directory and log in with a user name that has administrator privileges.
The URL is formatted http://gisserver.domain.com:6080/arcgis/admin.
- Click services, and choose 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.
- On the Service - <service name> (<service type>) page, scroll to the bottom and click edit.
- On the Service Properties dialog box, locate the "properties" section of the service JSON.
- Add the cacheControlMaxAge property to the section and specify the value (in seconds. The following is an example:
"properties": { "cacheControlMaxAge": "300",
- Click Save Edits.
On the Service - <service name> (<service type>) page, verify that the cacheControlMaxAge property and the value you specified for it appear in the Properties section.