Conditional GET Requests
Add conditional GET requests to occasionally offline OData applications that use an online store.
- The server sends the following HTTP headers:
- Cache-Control specifies if the server supports HTTP caching. no-cache and/or no-store values indicate that the server does not support HTTP caching. If the Cache-Control header value is max-age=sec (where <sec> is the maximum age in seconds of the cached resource), then the server supports HTTP caching.
- Last-Modified a timestamp indicating when the resource was modified.
- etag the version token of the resource (generated by the server).
- Before the HTTP client sends a request it verifies that the specified
resource exists in the cache with these headers:
Last-Modified, and etag. It then
sends the request including these headers:
- etag the same version token sent previously by the server.
- If-Modified-Since the same timestamp sent previously by the server in the Last-Modified header.
- When the server receives a request with the required headers, it checks the
resource. If the resource has been:
- Modified the server sends back the new resource with new Last-Modified and etag headers.
- Not modified the server sends back a 304 Not Modified response.
Online store support for HTTP conditional GET
These are filled with HTTP header values sent from the server responses. When a request is scheduled/executed, the online store checks these headers. If they exist for a particular response, the online store adds If-Modified-Since and etag headers to the HTTP request based on the sotred response headers. When a response arrives, the online store checks its status code. If it is 304 Not Modified, then the online store calls the server response with the "old" cached response. If the status code is 2xx, then the online store updates the cache and calls the server response with the new content.
- An updated flag is added to the odata response: the flag is always "true" except when the server sends back the 304 Not Modified response.