Hi, everyone.
My Wikipedia bot used to access Wikipedia by putting parameters into URLs, like this:
http://en.wikipedia.org/w/api.php?action=query&prop=info%7Crevisions&...
I put some parameters into POST data, though. Firstly, anything that I think ought to be kept relatively secret (such as login password), and secondly, anything that might be long (such as edited text or even edit summaries). Today I converted my bot to use bare URLs and put all the parameters in POST. Yet, I wonder if I should have an option in my bot for the user to use URL parameters instead of POST parameters. Bear in mind that although I'm coding with Wikipedia in mind, my bot is open source and intended to be used with any Mediawiki project.
I can see that there are avantages to putting parameters into POST data. Are there any advantages to a bot putting parameters into the URL?
Richard
2011/3/26 richardcavell@mail.com:
I can see that there are avantages to putting parameters into POST data. Are there any advantages to a bot putting parameters into the URL?
The only advantage I can think of is caching. If you're repeating the same request a number of times and want any caching proxies between you and the server (e.g. Wikimedia's Squid servers) to cache the result for you, you can put &smaxage=3600 (or any number of seconds) in the URL. This only works for GET requests and only when the URLs are exactly the same both times.
Roan Kattouw (Catrope)
Thanks for your reply.
I'm not entirely sure how caching works though. Are you describing a situation in which one requests exactly the same data (which would be pointless), or one in which one accesses different data from the same parameters (like stepping through articles in a category)?
Every login and edit request is a POST. The logout routine can use GET but will not be repetitious. Download routines can use GET. I'm a bit dubious about whether that's a good enough reason for me to dump additional code and a command line option into my bot, though.
Richard
-----Original Message----- From: Roan Kattouw roan.kattouw@gmail.com To: MediaWiki API announcements & discussion mediawiki-api@lists.wikimedia.org Cc: richardcavell@mail.com Sent: Sun, Mar 27, 2011 2:22 am Subject: Re: [Mediawiki-api] Is there an advantage to putting parameters in the URL?
2011/3/26 richardcavell@mail.com:
I can see that there are avantages to putting parameters into POST data. Are there any advantages to a bot putting parameters into the URL?
The only advantage I can think of is caching. If you're repeating the same request a number of times and want any caching proxies between you and the server (e.g. Wikimedia's Squid servers) to cache the result for you, you can put &smaxage=3600 (or any number of seconds) in the URL. This only works for GET requests and only when the URLs are exactly the same both times.
Roan Kattouw (Catrope)
2011/3/26 richardcavell@mail.com:
Thanks for your reply.
I'm not entirely sure how caching works though. Are you describing a situation in which one requests exactly the same data (which would be pointless), or one in which one accesses different data from the same parameters (like stepping through articles in a category)?
I'm talking about requesting exactly the same data, yes. This is not pointless in some scenarios, e.g. when many people are running your code on different machines (like in a web app), but if you're writing a stand-alone bot that runs on one machine, it'd be pointless, yes.
Roan Kattouw (Catrope)
mediawiki-api@lists.wikimedia.org