This is one of the series of articles devoted to different aspects of optimizing a web application powered by Zend Framework, for best performance.
In part 1, we take a look at the server requirements for running a Zend Framework application and the key server settings that effect performance in production environment.
This article in a form of general advices provides an overview of methods as well as recommendations to run high traffic websites on a middle priced virtual private server.
Warning: this article contains Linux shell commands. Use at your own risk.
According to official Zend Framework website, Zend Framework requires a PHP 5 interpreter with a web server configured to handle PHP scripts correctly. When planning a project, one has to decide a platform used for deployment. A Linux powered system is a common choice. Let's make a checklist of what we need for a common Zend Framework powered web application:
server.modules = (
"mod_rewrite",
# "mod_redirect",
# "mod_alias",
"mod_access",
# "mod_cml",
# "mod_trigger_b4_dl",
# "mod_auth",
# "mod_status",
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
# "mod_evhost",
# "mod_userdir",
# "mod_cgi",
"mod_compress",
# "mod_ssi",
# "mod_usertrack",
"mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )
For running Zend Framework application you have to add rewrite rule in configuration file. It is similar to Apache rewrite rule in a way that it rewrites all requests to the index.php that runs your bootstrap. url.rewrite-once = (
".*\?(.*)$" => "/index.php?$1",
".*\.(js|ico|gif|jpg|png|swf|css|html)$" => "$0",
"" => "/index.php"
)
To enable gzip compression, make sure you have the following lines in your configuration file: #### compress module
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ("text/plain", "text/html", "text/css", "text/javascript")
Next, configure the expire module to send Expires headers with the dates far in the future: $HTTP["url"] =~ "\.(png|jpg|js|swf|css)$" {
expire.url = ( "" => "access 7 years" )
}
This is aggressive caching approach. Users always get files from browser cache after first access via network. Once you change asset files' contents, you will have to rename asset files so that users would download new versions. (i.e. provide versioning numbers when including scripts or css files - scriptname-1.0.1.js). < Prev | Next > |
---|