|
|||
|
|||
|
Ubuntu Apache Performance Tip In a previous post I discussed using Cache-Control to tune web server performance. In this post I will include how to do this specifically on Ubuntu Server. Cache-Control directives in a HTTP request header modify the way the browser caches your web pages. Of course you want to encourage the browser to cache as much as it can since this reduces the load on your server. At the same time there is times that caching is not a good idea (Dynamic Pages, Secure Pages, etc) but generally these types of pages are limited in number so a vast majority of a website could use fairly aggressive caching directives. To enable in Ubuntu simply enable the included expire, headers, and deflate modules. To do this type the following: # cd /etc/apache2/modules-available; sudo a2enmodule expire; a2enmodule headers; a2enmodule deflate [enter]# sudo vi /etc/apache2/httpd.conf [enter] Add the following lines: ExpiresActive OnExpiresDefault A86400 The above will by default cache everything with an expiration (Thats the time that content will be held in cache) for 86,400 seconds or 1 day. You will also notice the following responses on browser refreshes: HTTP/1.x 304 Not Modified Date: Mon, 04 Jun 2007 01:57:45 GMT Server: Apache/2.2.3 (Ubuntu) PHP/5.2.1 Connection: Keep-Alive Keep-Alive: timeout=15, max=100 Etag: 1f35fd-49d-bbad4380 Expires: Tue, 05 Jun 2007 01:57:45 GMT Cache-Control: max-age=86400 The code 304 indicates nothing has been modified, so no further download or bandwidth is needed. This results in savings for you! Now you may want to be aggressive for certain files types like Images or CSS, so you can select additional time for certain mime types like so: # sudo vi /etc/apache2/httpd.conf [enter]Add the following line: ExpiresByType image/jpg A604800 ExpiresByType image/gif A604800 ExpiresByType text/css A604800 This sets by type the expiration time (in this case 1 week).
Other ImprovedSource Articles: |
|||
ImprovedSource. Copyright 2007
+ Contact Us + Home
+ Search
+ RSS Feed |
|||