diff --git a/http-web-services.html b/http-web-services.html index 59a2a66..b72a875 100755 --- a/http-web-services.html +++ b/http-web-services.html @@ -219,7 +219,7 @@ reply: 'HTTP/1.1 200 OK' …further debugging information omitted…
  1. As I mentioned at the beginning of the chapter, urllib.request relies on another standard Python library, http.client. Normally you don’t need to touch http.client directly. (The urllib.request module imports it automatically.) But we import it here so we can toggle the debugging flag on the HTTPConnection class that urllib.request uses to connect to the HTTP server. -
  2. Now that the debugging flag is set, information on the the HTTP request and response is printed out in real time. As you can see, when you request the Atom feed, the urllib.request module sends five lines to the server. +
  3. Now that the debugging flag is set, information on the HTTP request and response is printed out in real time. As you can see, when you request the Atom feed, the urllib.request module sends five lines to the server.
  4. The first line specifies the HTTP verb you’re using, and the path of the resource (minus the domain name).
  5. The second line specifies the domain name from which we’re requesting this feed.
  6. The third line specifies the compression algorithms that the client supports. As I mentioned earlier, urllib.request does not support compression by default. @@ -451,7 +451,7 @@ reply: 'HTTP/1.1 200 OK'

    How httplib2 Handles Last-Modified and ETag Headers

    -

    The Cache-Control and Expires caching headers are called freshness indicators. They tell caches in no uncertain terms that you can completely avoid all network access until the cache expires. And that’s exactly the behavior you saw in the previous section: given a strong validator, httplib2 does not generate a single byte of network activity to serve up cached data (unless you explicitly bypass the cache, of course). +

    The Cache-Control and Expires caching headers are called freshness indicators. They tell caches in no uncertain terms that you can completely avoid all network access until the cache expires. And that’s exactly the behavior you saw in the previous section: given a freshness indicator, httplib2 does not generate a single byte of network activity to serve up cached data (unless you explicitly bypass the cache, of course).

    But what about the case where the data might have changed, but hasn’t? HTTP defines Last-Modified and Etag headers for this purpose. These headers are called validators. If the local cache is no longer fresh, a client can send the validators with the next request to see if the data has actually changed. If the data hasn’t changed, the server sends back a 304 status code and no data. So there’s still a round-trip over the network, but you end up downloading fewer bytes.