Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 122010
 

Turn on expire headers in Apache

Answer:

By turning on the expire headers, browser will cache the files serving from Apache more aggressively, so as to reduce traffic loading to the Apache web server.

Steps:

Add the following lines to the Apache configuration (httpd.conf)

<IfModule mod_expires.c>
    ExpiresActive On

    # Cache all files for 2 weeks after access (A).
    ExpiresDefault A1209600
    
    # Do not cache dynamically generated pages.
    ExpiresByType text/html A1
</IfModule>

Restart Apache to take effect

# apachectl -k graceful

Assume the module mod_expires is enabled

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>