DokuWiki — Dealing with very large pages

On one of my wikis I have a complex page of about 575 KB source text size. After any modifications it runs into the default maximum execution time for PHP of 30s and only an error message is displayed.

As we can't make DokuWiki any faster, and the hardware needs to stay the same as well, the only alternative is to increase the time limit.

The PHP maximum execution time is set via the max_execution_time INI setting. It can also be adjusted at runtime using the set_time_limit() function.

Altering the value of max_execution_time works, but it affects more than just the DokuWiki instance. So this is not ideal.

The best solution is to use set_time_limit() during DokuWiki startup to set a higher time limit. This is actually fairly easy to accomplish: Code added in the file DOKU_BASE/conf/local.protected.php is executed early during DokuWiki startup. So creating this file if necessary and adding e.g.

set_time_limit(90);

will solve the problem.

The complete file would look like this (if no other code is needed at startup):

local.protected.php
<?php
	set_time_limit(90);
?>

An additional advantage of using set_time_limit() instead of adjusting max_execution_time is that the file …/conf/local.protected.php would be copied along with the rest of the DokuWiki instance to backup sites, thus ensuring that the adjusted timeout is applied there as well without needing to fiddle with global PHP settings on those sites.

Note: The new time limit should be chosen large enough that it works for the DokuWiki instance as well as any backup/mirror sites. The backup/mirror sites might use different hardware, thus exhibiting different performance compared to the main site. The requirements of the slowest site should be used to determine an appropriate value.