KBD

Keith Devens .com

Thursday, May 17, 2012 Flag waving
C++ is history repeated as tragedy. Java is history repeated as farce. – Scott McKay
← 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.

May 2012
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



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

Recent comments XML

new⇒Acknowledging the Arrival of Peak Government

In many ways, Peak Oil is​responsible for this new​uselessness of the big g...

Revence: May 16, 6:35am

new⇒Tab EXSPLOSION

Right now, I, too, have too many​tabs open. A rough count says​25.
Right. ...

Revence: May 16, 6:21am

George W. Bush: ‘I’m for Mitt Romney’ - ABC News

A marked difference (departure,​even) from the KBD of eight--yea,​even four...

Revence: May 15, 1:55pm

WebOb — WSGI request and response objects

Google App Engine forces one to​learn these....

Revence: May 15, 1:52pm

Generated in about 0.186s.

(Used 8 db queries)