My web server: FreeBSD 10.0, Apache 2.4, Perl 5.16, HTML::Template::Pro 0.9510
When I try to run any perl script calling HTML::Template::Pro templates larger than 8,191 bytes, I get following error in httpd: [cgid:error] malformed header from script 'test.pl': Bad header: <!doctype html> Running the script from command line does produce the expected output and no error, so I am assuming the cause of the error is related to Apache. Here is the simple perl script 'test.pl' that I tested with: #!/usr/bin/perl use strict; use HTML::Template::Pro; my $tmpl = HTML::Template::Pro -> new(filename => 'test.tmpl'); print "Content-Type: text/html\n\n"; $tmpl -> output(); ..and the HTML::Template::Pro template 'test.tmpl': <!doctype html> <html> <body> <p>blah blah</p> </body> </html> I ran test.pl in the browser and everything was fine at first, no error. Then I started adding a lot of blah blahs to the template file until the size of the template file hit exactly 8,192 bytes, at which time it crashed with a 500 and with the above error logged in the httpd-error.log. If I delete even a single character from the template file so it goes below 8K, the script runs again. I have absolutely no idea why this happens. By the way, large html files do not crash Apache, nor do Perl scripts printing html code directly (without HTML::Template::Pro. I tried both to the extreme, creating MBs of html code and wasn't able to crash anything at all. If I switch to mod_cgi instead of mod_cgid, the error appears exactly when template file hits 4K in size. So it is 8K for mod_cgid and 4K for mod_cgi. What is it in Apache that imposes such limits on the size of my templates and how can I lift/increase them?