[GIS] ‘invalid url’ on ArcGIS server REST API

arcgis-servercachehttp-headersnet

From time to time, the services on our ArcGIS server will not be available, and when requesting tiles, I will get a 'invalid url'. This is okay, sometimes it is scheduled downtime, maintenance or just some of our server scripts not bringing the services up again.

We also have a cache server in front of the ArcGIS server, that can serve often requested tiles really fast, w/o sending the request to the server.

The cache server is set up to store the successful requests for a period of time. The thing that bothers me, is that the page 'invalid url' is served with the http code OK 200, and thus making our cache server store it.

Of course, I could make exceptions, probably based on mime-type or something, but that's not the optimal solution.

Example of the invalid url page

I would actually like to know if it is possible to alter the 'invalid url' error page, with another http code, such as Bad request 400 or Not implemented 501, both which would make Varnish behave.

EDIT:
I should mention that the ArcGIS server runs in a .NET environment.

Best Answer

The JSON response from the server should contain an error object (in JSON) that you might be able to use to tell your cache server to dismiss.

I wasn't able to match your "Invalid URL" using ESRI's online servers, but got a similar light-pink error with the following URL:

http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/NotAMap/MapServer

Which, if you request asking for JSON will give you this:

http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/NotAMap/MapServer?f=json

If you wanted to be extra sneaky, set up an HTTP filter in IIS that transforms the 200 OK response into a 400 bad request response if the error object is detected in the response body.

Related Question