How do I increase the apache timeout directive in .htaccess? I have a LONG $_POST['script'] that takes a user probably 10 minutes to fill in all the data. The problem is if it takes too long than the page times out or something and it goes to a webpage is not found error page. Would increasing the apache timeout directive in .htaccess be the answer I'm looking for. I guess it's set to 300 seconds by default, but I don't know how to increase that or if that's even what I should do... Either way, how do I increase the default time? Thank you.
3 Answers
if you have long processing server side code, I don't think it does fall into 404 as you said ("it goes to a webpage is not found error page")
Browser should report request timeout error.
You may do 2 things:
Based on CGI/Server side engine increase timeout there
PHP : http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time - default is 30 seconds
In php.ini:
max_execution_time 60
Increase apache timeout - default is 300 (in version 2.4 it is 60).
In your httpd.conf (in server config or vhost config)
TimeOut 600
Note that first setting allows your PHP script to run longer, it will not interferre with network timeout.
Second setting modify maximum amount of time the server will wait for certain events before failing a request
Sorry, I'm not sure if you are using PHP as server side processing, but if you provide more info I will be more accurate.
-
It is PHP. I've applied
max_execution_time = 10080
to the php.ini. So far I troubleshooted it 5 times on 3 browsers with success. Would this alone allow a user to be idle on a post form page for 3 hours (10080 sec = 3 hours) before clicking submit and avoiding the webpage is not found error? Like I said I've been good so far but still don't feel 100%. Also, is the Timeout 300 changed to Timeout 10080 OK? Would that exceed the max allowed time and would this even be necessary to avoid the problem I'm experiencing. Thank you for the great answer!– GrahamMar 9, 2012 at 9:32 -
1As I said, your apache httpd.conf affect network related timeouts, and php.ini settings set maximum period of time for which script is allowed to run.– rkosegiMar 9, 2012 at 9:45
-
Where in the httpd.conf do we put TimeOut 600? That line does not already exist in mine. Does it go in the 'DirectoryIndex' block or the 'Directory' block or somewhere else?– covfefeNov 9, 2015 at 21:31
-
@user3004041 : Did you read link above about TimeOut directive? it goes to server config or virtualhost. Per-directory connection settings doesn't make any sense.– rkosegiNov 10, 2015 at 7:02
-
1@Graham re
max_execution_time
- that is for a long running script. E.g. a large file upload. AFAIK, doesn't affect how long a user can be idle. reTimeout 10080
. I think not a good idea - ties up more resources unnecessarily. httpd.apache.org/docs/2.0/mod/core.html#timeout says "timer used to be 1200 but has been lowered to 300, which is still far more than necessary..." Apr 17, 2019 at 20:13
Just in case this helps anyone else:
If you're going to be adding the TimeOut
directive, and your website uses multiple vhosts (eg. one for port 80, one for port 443), then don't forget to add the directive to all of them!
-
1Isn't this setting valid only in server configuration context? And it cannot be set in a vhost context seperately?– robschFeb 20, 2020 at 12:52
This solution is for Litespeed Server (Apache as well)
Add the following code in .htaccess
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]