Friday, June 18, 2010

Search pages should not use POST

This'll be a short post, because it's a simple thing. If you're writing a web site search form, it should not use HTTP POST to submit the query. This breaks the back button ("do you want to resubmit?") and is a poor fit for the semantics of the HTTP requests. What you want to use is a regular GET request.

The main problem with this is that sometimes you don't want people to resubmit a search form because searches are computationally expensive. The solution is not to make searching more painful; the solution is to cache the results on the server for a few minutes with memcached. It's easy to install and use, very fast, and popular enough to be widely available. Use memcached and HTTP GET requests, and your web site will be closer to Just Working.

No comments:

Post a Comment