[mod_python] cookies and redirects

mike bayer mike_mp at zzzcomputing.com
Fri Nov 5 11:31:26 EST 2004

> John Aherne wrote:
> External redirect, particularly a 307 redirect for HTTP/1.1 clients, is
> generally the best way to handle changing a location in response to a
> request.  Using a 307 means the client's back button works right, reload
> works right, and the URL location bar works right.

I have never seen a 307 redirect used before, so I will admit my ignorance
of it as well as its usablity.  But big sites like Yahoo! etc. use "302
Found" combined with the Location: header (I just double checked) to send
the client elsewhere, as does the "Redirect" directive in Apache.

Which is not to say the 307 is not a better way, but is it very well
supported and predictable across all browsers ?

If you really want a seamless redirect with zero side effects, an internal
redirect, i.e. an server-side change of output within the scope of one
request, is best, if your application can support them.

Also, an external redirect is often used specifically to prevent reloads
and back button usage, as in the case of an ecommerce submit form that you
dont want submitted a second time by accident.

I tend to use external redirects only for that reason, i.e. to prevent
form reloads, and otherwise internal redirects for everything else, which
are particularly useful since you can more easily preserve the request
state among the original and redirected pages.

- mike

More information about the Mod_python mailing list