Site icon GetPageSpeed

Apache Performance Ultimate Configuration

We open our work for free. Here is drop-in Apache performance configuration file to enable maximum performance as per modern performance guidelines. Here is what it does:

Most of performance tips by Google PageSpeed Insights will be addressed by this configuration.

Simply save it to /etc/httpd/conf.d/z_performance.conf. The filename starts with “z” to make sure it is loaded last in queue of configuration files.

Ultimate Apache Performance file: z_performance.conf

AddType text/javascript .js
AddType application/java-archive .jar
# Correct MIME type to use (as per Wikipedia). Also this ensures that IE8 can read the icon
AddType image/x-icon .ico
AddType image/x-icon .cur
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

# enable KeepAlive for persistent connections to work
# KeepAlive On

FileETag none

# 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 (so does IE 6)
BrowserMatch ^Mozilla/4\.[0678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE\s7  !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|gz|jar|rar|zip|7z)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

# enable expirations
ExpiresActive On
ExpiresByType text/javascript "access plus 2 years"
ExpiresByType text/css "access plus 2 years"
ExpiresByType image/gif "access plus 2 years"
ExpiresByType image/jpeg "access plus 2 years"
ExpiresByType image/png "access plus 2 years"
ExpiresByType image/x-icon "access plus 2 months"

# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"

Header unset X-Powered-By
Header set X-Powered-By "ASP.NET"

# protect .svn directories
RedirectMatch 404 /\\.svn(/|$)

AddDefaultCharset Off

After you’re done saving the file, simply reload Apache service to apply optimizations:

service httpd reload
Apache Performance Injection Complete
Exit mobile version