Comment 5 for bug 521927

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 521927] Re: constructing a sessions unnecessarily makes two http calls

On 17 February 2010 03:53, Leonard Richardson
<email address hidden> wrote:
> If you have a cache set up, it should be making conditional requests,
> and the conditional requests should be returning 304 ("Not Modified")
> because the service root only changes when we do a new release of
> launchpadlib. If we added a reasonable Cache-Control header when serving
> the WADL and JSON, launchpadlib would only try to retrieve these
> documents, say, once a week. This seems more practical than cramming the
> WADL and JSON representations into the same response and getting rid of
> one of the two requests.

I suspect a fair amount of time is in starting the connection, so just
sending not modified may not totally fix things, but it would
certainly help, and you're right it would be cleaner than trying to
squash them together. In fact the very crude view given by 'bugclient
--debug' does show some lag while getting the body - and the wadl is
over 1MB(!!) so avoiding that startup would help.

The requests obviously are not sending if-not-modified-since etc and
the server is sending an etag but no date.

send: 'GET /beta/ HTTP/1.1\r\nHost:
api.edge.launchpad.net\r\nAccept-Encoding: identity\r\nte: deflate,
gzip\r\nAuthorization: OAuth realm="OAuth", oauth_nonce="66438850",
oauth_timestamp="1266365634", oauth_consumer_key="Hydrazine",
oauth_signature_method="PLAINTEXT", oauth_version="1.0",
oauth_token="uuuuuuuuuuuuuuu",
oauth_signature="uuuuuuuuuuuuuuuuuuuu"\r\naccept:
application/vnd.sun.wadl+xml,
application/vd.sun.wadl+xml\r\nuser-agent:
Python-httplib2/$Rev$\r\n\r\n'
reply: 'HTTP/1.1 200 Ok\r\n'
header: Date: Wed, 17 Feb 2010 00:23:01 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: Content-Type: application/vnd.sun.wadl+xml
header: Content-Length: 1099105
header: Etag: "b81864b7425d7c9d586096a3362cf1f47e8ea99d"
header: Vary: Cookie,Authorization,Accept
header: Via: 1.1 wildcard.edge.launchpad.net
> (Do you have a cache set up? Was that HTTP dump on a fresh
> installation?)

I think I do have a cache; at least my client code is following the
launchpadlib instructions as they were a couple of months ago. You
can see it in lp:hydrazine.

~/.cache/launchpadlib contains

total 5928
-rw-r--r-- 1 mbp 1324 2010-02-17 11:14
api.edge.launchpad.net,beta,-application,json,5600078570afb551b07f3697ec032007
-rw-r--r-- 1 mbp 709 2010-02-17 11:14
api.edge.launchpad.net,beta,pillars-application,json,6a86736a4b082cccc2d62ff7046425b2
-rw-r--r-- 1 mbp 1099573 2010-02-17 11:13
api.edge.launchpad.net,beta,-application,vnd.sun.wadl+xml,8f29db2e0dac01f431816a14846bf440
-rw-r--r-- 1 mbp 1541 2010-02-17 10:58
api.edge.launchpad.net,beta,bzr-svn,+bug,522836-application,json,756aa788a75cb38ec3e0973cfc78ed8a
-rw-r--r-- 1 mbp 4626 2010-02-17 10:58
api.edge.launchpad.net,beta,bzr-application,json,586e8acb7964c1acbc76fee01d8345af
-rw-r--r-- 1 mbp 3642 2010-02-17 10:58
api.edge.launchpad.net,beta,bugs,522836-application,json,a27f0ded3a6d64fe9547b7754f99dff0
-rw-r--r-- 1 mbp 1570 2010-02-17 10:58
api.edge.launchpad.net,beta,bugs,522836,bug_tasks-application,json,725c3fbc2be928972c5c8393b32f849e
-rw-r--r-- 1 mbp 2672 2010-02-17 10:49
api.edge.launchpad.net,beta,bugs,522603-application,json,dfb1c643c9c8b5441c5e8396cf603959
-rw-r--r-- 1 mbp 2734 2010-02-17 10:49
api.edge.launchpad.net,beta,bugs,240294-application,json,b45530870809ef904cd17edcc0889990
-rw-r--r-- 1 mbp 2307 2010-02-17 10:49
api.edge.launchpad.net,beta,bugs,240924-application,json,3b262a0cb121d0133f7ef01d8a879125
....

--
Martin <http://launchpad.net/~mbp/>