97 | | TBD |
| 97 | These API changes do not really affect the mapagent interface. From a calling client's perspective, they should still be able to send v1.2.0 GETTILEIMAGE requests with the same parameters and take advantage of HTTP caching behind the scenes. Behind the scenes the GETTILEIMAGE operation handler simply needs to check for the existence of a "If-Modified-Since" request header to take on a new code path. |
| 98 | |
| 99 | A rough pseudocode overview of this process would be |
| 100 | |
| 101 | {{{ |
| 102 | |
| 103 | if (ifModifiedSince header exists) { |
| 104 | extract date from header |
| 105 | call GetTileCreationDate |
| 106 | if (tileCreationDate != NULL) { |
| 107 | if (tileCreationDate is newer than header date) { |
| 108 | call new GetTile |
| 109 | write image from MgTile into result |
| 110 | write date from MgTile into last modified response header |
| 111 | write expires date a long period from that date (6 months? 1 year?) |
| 112 | } else { |
| 113 | set status code of 304. Write nothing into the result. Outer CGI/Apache/ISAPI handler is expected to handle this and write out the appropriate responses (see below) |
| 114 | } |
| 115 | } else { |
| 116 | call new GetTile |
| 117 | write image from MgTile into result |
| 118 | write date from MgTile into last modified response header |
| 119 | write expires date a long period from that date (6 months? 1 year?) |
| 120 | } |
| 121 | } else { |
| 122 | call new GetTile |
| 123 | write image from MgTile into result |
| 124 | write date from MgTile into last modified response header |
| 125 | write expires date a long period from that date (6 months? 1 year?) |
| 126 | } |
| 127 | }}} |
| 128 | |
| 129 | In our applicable CGI/Apache/ISAPI handlers, their additional responsibilities are to: |
| 130 | |
| 131 | * Pack any HTTP request headers into the request metadata of the MgHttpRequest before executing it. In the case of this API, look for if-modified-since |
| 132 | * Handle the 304 internal status and write out any applicable response headers from the MgHttpResult that operations supporting HTTP cacheability (ie. The GETTILEIMAGE) should provide. |
| 133 | |
| 134 | MgHttpRequestMetadata and MgHttpHeader classes are not currently used in any of the existing CGI/Apache/ISAPI handlers. We should use them for this purpose. |