My request timeouts when I load Mach-II, how can I fix this?
Table of Contents
Mach-II 1.5 or lower
It is not uncommon that as a Mach-II application grows, it may start to exceed the request timeout when it is loading. This occurs because many objects are instantiated during the application startup (or reload) and cached as singletons for performance and reused during the request lifecycle. You can fix this by adding a ColdFusion? directive to temporarily increase the request timeout.
Application.cfm
Add this code before including the mach-ii.cfm bootstrapper:
<cfif NOT StructKeyExists(application, MACHII_APP_KEY)> <cfsetting requesttimeout="120" /> </cfif> <cfinclude template="/MachII/mach-ii.cfm" />
Application.cfc
Add this directive in your onApplicationStart() method before calling loadFramework():
<cfsetting requesttimeout="120" /> <cfset loadFramework() />
Mach-II 1.6 or higher
Mach-II 1.6 added a new bootstrapper attribute called MACHII_ONLOAD_REQUEST_TIMEOUT which defaults to 120 seconds. If your application exceeds the default setting of 120 seconds, the request will timeout. Increasing this setting will fix the problem:
Application.cfc
Example of MACHII_ONLOAD_REQUEST_TIMEOUT:
<cfcomponent displayname="Application.cfc" extends="MachII.mach-ii">
<!---
PROPERTIES - APPLICTION.CFC SPECIFIC
--->
<cfset this.name = "lightpost" />
... additional application settings .....
<!---
PROPERTIES - MACH-II SPECIFIC
--->
<cfset MACHII_CONFIG_PATH = ExpandPath("/path/to/config/mach-ii.xml") />
<cfset MACHII_APP_KEY = this.name />
<cfset MACHII_CONFIG_MODE = -1 />
<cfset MACHII_VALIDATE_XML = false />
<cfset MACHII_ONLOAD_REQUEST_TIMEOUT = 300 />
... Application Event Methods (onApplicationStart, etc.) ...
</cfcomponent>
Application.cfm
This would be the same as in the 1.5 or lower Application.cfm example. However, note that Mach-II 1.6 deprecated the Application.cfm bootstrapper and it is recommended to not use Application.cfm (mach-ii.cfm bootstrapper).
