Improve Response Time with Header Cache

11 May, 2009

Recently i have been developing web application with Zend framework 1.8 (the latest release version). The latest version of Zend framework are much better in terms flexibility  of configuring the Bootstrap file by extending Zend_Application_Bootstrap_Bootstrap. Personally, i used dimensional arrays style of config to set up in different  environments.

I have done some simple optimisation technique for the website response time by following the guidelines provide at YUI (Yahoo Developer Center). One of the problem  i faced, was the response time of JavaScript and CSS file was to long. I use the function below in the bootstrap to cache both of the files and compression with the Accept-Encoding header in the HTTP request.


protected function _initResponse()
{

  // Create a new HTTP response object
  $response = new Zend_Controller_Response_Http();

  // Set the response headers : the value below are only set for example.
  $response->setHeader('language', 'en')
           ->setHeader('content-language', 'en')
           ->setHeader('Content-Type', 'text/html; charset=utf-8')
           ->setHeader('Accept-Encoding', 'gzip, deflate')
           ->setHeader('Expires', 'max-age=7200, must-revalidate’, true)
           ->setHeader('Cache-Control', 'public', true)
           ->setHeader('Cache-Control', 'max-age=7200') //only for testing
           ->setHeader('Pragma', '', true);

  // Assign the response to the front controller
  $this->getPluginResource(’frontController’)->getFrontController()->setResponse($response);
}

Refer to this W3C documentation for the meaning of the attributes : http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

First Reload Result :

Firebug Net reload result

Second Reload Result :

Firebug Net Reload Result

Entry Filed under: Technology, Zend. Tags: , .

Leave a Comment

hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Charles Ling

Founder of ecomjunction.com

My Favourite Web

 

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

Tags

Adobe bitcomet book coding Firefox Intelligent Intelligent Web J2ME Java javascript javascript framework jQuery Jsp jsr 172 kite runner LWUIT Machine Learning Mysql novel Nuance Talks painted veil parse Personalization Photoshop PHP plug-in privacy programming protocol buffer proxy Security server tcp Technology Tomcat web web 2.0 Web Service web services wep Wireless WSDL wsf wso2 xml

Archives

Delicious Bookmark

Join ME