User Tools

Site Tools


Apache Performance & Security



  • The Firefox plugin YSlow is a good tool to measure web site performance.
  • See also benchmarks with Apache Benchmark

Apache config for production Servers


The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.

See also Apache 2.2 documentation.

Activate mod_deflate globally

This directive will compress all content except images per default.

# gzip files to improve performance with mod_deflate
<IfModule mod_deflate.c>
# Compress everything except images
    <Location />
        # Insert filter
        SetOutputFilter DEFLATE
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        # MSIE masquerades as Netscape, but it is fine
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        # Don't compress images and zip files
        SetEnvIfNoCase Request_URI \
        \.(?:gif|jpe?g|png|zip)$ no-gzip dont-vary
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary


This module controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. The expiration date can set to be relative to either the time the source file was last modified, or to the time of the client access.

These HTTP headers are an instruction to the client about the document's validity and persistence. If cached, the document may be fetched from the cache rather than from the source until this time has passed. After that, the cache copy is considered “expired” and invalid, and a new copy must be obtained from the source.

See also Apache 2.2 documentation

Avtivate Expires globaly

Just add the following snippet in to your httpd.conf:

# enable expirations with mod_expires
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 2 weeks"

Disable ETags

Set the following in your Apache httpd.conf:

# deactivate ETags
FileETag None

Measures to improve the YSlow value

See here for more information about YSlow.

The YSlow performance mantra

  1. Make fewer HTTP requests
  2. Use a CDN
  3. Add an Expires header
    • to configure (global) expires header with Apache see mod_expires
  4. Gzip components
    • to configure (global) compression with Apache see mod_deflate
  5. Put CSS at the top
  6. Put JS at the bottom
  7. Avoid CSS expressions
  8. Make JS and CSS external
  9. Reduce DNS lookups
    • Use DNS A Records
  10. Minify JS
  11. Avoid redirects
  12. Remove duplicate scripts
  13. Configure ETags

Measure Memory consumption

ps -ylC httpd --sort:rss

RSS - resident set size, the non-swapped physical memory that a task has used (in kiloBytes).

/srv/ · Last modified: 2010/07/05 07:48 (external edit)