I am trying to find some online tool for compressing and optimizing my perl. Is there any benefit to removal of (at a minimum) whitespace and comments from server side cgi?
-
Why do you want to do this? What are your performance issues? How do you deliver your cgi, what webserver do you use? – matthias krull Mar 10 '12 at 16:19
-
I use Apache2, but I'm not sure what you mean by how I deliver? I just want to reduce the wait time (between request and response of index.cgi) – harmonic Mar 10 '12 at 16:41
2 Answers
Perl source undergoes a compilation phase, it is not directly interpreted. Perl code is executed at the server, not delivered to the client. Unlike JavaScript, there is no benefit from minimisation.
If you want to optimise, measure first where the bottle-neck is. I presume that switching from CGI to a persistent technology will give you a big pay-off.
Related:
- How can I compile my Perl script so to reduce startup time?
- How can I reduce Perl CGI script start-up time?
Edit:
You mention in a comment that you deploy on Apache httpd. To reduce start-up time without changing existing code, install mod_perl2 and run your CGI programs with the perl-script
handler. In the long term, switch over your code base from CGI to PSGI and deploy on Plack::Handler::Apache2, or preferably, if you also have an FastCGI adapter for the web server, Plack::Handler::Net::FastCGI.