Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

I'm programming a Perl script for the web that will get executed through a form very frequently by many users at the same time.

I got the following question...

What will use less server resources when getting executed through a form: a GET or POST type of submission?

Thanks,
Ralph :)

Replies are listed 'Best First'.
Re: Post vs. Get
by extremely (Priest) on Feb 21, 2001 at 11:57 UTC
    Neither will use enough to matter. I can make a case both ways and would be that it varies more between servers than it does between cases. POST sends a little more data but putting the data in a header eases the burden of parsing the data. POST creates a buffer for the STDIN pipe but GET burdens the Environment of the shell.

    My advice? Spare your users the ugly URLs and use POST. If that advice falls on deaf ears, then I recommend you use the one you are more comfortable with. Your time is more valuable than 10 times the server resources you would ever save.

    And if you use Perl, for goodness sakes use CGI; is your friend. Then you can use either and it will work just the same. (well, unless you move more than 8 or 16 KB of data or need file uploads, then POST is your only rational choice.)

    --
    $you = new YOU;
    honk() if $you->love(perl)

      Whether you use GET or POST depends on what you're doing. See section 9.1.1 (Safe Methods) of RFC 2616.

      In brief, if submission of the form causes something to change, use POST. If you're just returning some customised information according to the query (like a search engine), use GET.

      Can you use CGI.pm to tell whether a parameter was POSTed or GETed? I have seen web sites do this and am just curious.

      Dave
        CGI.pm has request_method() which can be used for this.

        If you're just using plain CGI, $ENV{'REQUEST_METHOD'} tells you the same thing.