Bad website search

August 10, 2008

The user interface for performing a search on a website is pretty much a solved problem. You enter your search terms, you click the search button, and you get taken to the first page of search results. If what you’re looking for isn’t on the first page of results, you can go to the next page of results. The current page of results you’re looking at is stored as an HTTP GET parameter in the URL, so you can easily jump to the nth page by changing that parameter.

That’s the right way of doing a search UI. Boardwalk Properties, and its sister sites Cambridge Pads and Boston Pads (and possibly others), managed to do it completely wrong. Instead of storing what page of results you’re looking at a URL parameter, they store it on the server and associate it with your cookie.

To actually browse the pages of search results, the links at the bottom each page for the next and previous pages just link to resultsdb.php?direction=1 and resultsdb.php?direction=0 respectively. It works fine if all you’re doing is going forwards and backwards one page at a time. But these links are just plain vanilla GET links, and they affect the server state. This violates the basic principle that GETs should be idempotent.

This has a number of bad consequences. Refresh the page? Oops, you just advanced to the next page (or the previous page). Try to view the source? Depending on your browser, it might send another GET request, thus giving the source of the next page of search results, and putting you on the wrong page the next time you try to change pages. You also can’t jump to an arbitrary page, you can only move one page at a time.

And since you only have one cookie, you can’t do multiple searches in different tabs or windows at the same time. If you start a new search in a new window and try to change pages in an older search, you’ll suddenly find yourself amidst the new search instead.

I don’t know how they messed up their search so badly; since they’re already running PHP it ought to be trivial to change. Every website developer should understand the basic principle that GET requests should not modify server state.

Comments are closed.