KBD

Keith Devens .com

Friday, September 3, 2010 Flag waving
I was talking recently to a friend who teaches at MIT. His field is hot now and every year he... – Paul Graham
← EiffelStudio →

Daily link icon Thursday, April 18, 2002

GET after POST

Adam explains something I've been too dense to fully understand until now. "Here's the situation, if you care. (If you do interactive DB sites, you might care.)" I do, and I do.

In fact, the way he recommends doing redirects to avoid "the scary browser warning about reposting form data" is exactly the same way I've been doing the programming for the site I'm developing. The thing is that I didn't put two and two together to realize exactly why it was working the way it was. I mean, I suppose I understood it, but I didn't actually think about it, systematize it, and put it in a pithy formulation like "GET after POST". You da man, Adam.

When I've developed stuff for myself I've tended to just stick everything in one (physical) page if it's not inappropriate (since who cares? it's just for me), and I was careful to not resubmit after getting the scary browser warnings. However, this isn't acceptable for developing public sites, which is what I've been working on. It's even more important when you're dealing with money: "In general you don't want to repost form data, because you'll end up submitting another order for a set of books."

The only thing I'm still wondering is exactly what happens when you hit back in your browser after being redirected. Does the browser refetch the page that redirected you from the server, or does it just pull it from its cache? I suppose that depends on your HTTP caching settings you send to the browser? And can you still use the same technique if you redirect to the current page?

Finally, I share Adam's complaints: "In fact, most books and references on web programming tend to have awful advice when it comes to using GET and POST. Lots of sites use POST for search boxes. This means that you can't bookmark or link to a search." I've always been pissed at Webster's site for this very reason. In fact, I think at least part of the reason everyone uses dictionary.com to link to definitions is because they use GET while m-w.com uses POST. In fact, Webster even allows you to use GET (I found that through my own experimentation), but in their wisdom they use POST for their form.

← EiffelStudio →

Comments XML gif

Comments closed.

September 2010
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
2627282930 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

new⇒Call a function from a string in Python

or​use:
?!code:language=python
def​fce(arg1=None,arg2=None):
#some​usefu...

Richard: Sep 2, 1:08pm

new⇒Spider solitaire

Been playing 4S Spider for a couple​of years. Only recently did I start​to ...

jimibd: Sep 2, 3:16am

Generated in about 0.167s.

(Used 8 db queries)