Google has everything you need to know about speeding up your website including an online tool called Page Speed Online. Using this tool will provide everything you need to get your site faster. Here's the results for the askapache home page, which is very fast.
############################################## # HEADERS and CACHING # ############################################## ExpiresActive On ExpiresDefault M600000 FileETag MTime #Header unset ETag #Header unset Last-Modified Header unset P3P Header unset Pragma #Header unset Cache-Control Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT" Header set Cache-Control "public,max-age=29030400" ############################################## # COMPRESSION # ############################################## AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript application/javascript text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html ############################################## # HEADERS and CACHING # ############################################## ExpiresActive Off FileETag INode Size #Header unset ETag Header append Cache-Control "public" #Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT" Header unset Last-Modified Header unset P3P Header unset Pragma #ContentDigest On Header set Cache-Control "must-revalidate, proxy-revalidate, max-age=60" ExpiresActive On ExpiresDefault A60 Header unset P3P Header unset Pragma #Header unset ETag #Header unset Cache-Control #Header unset Expires #Header unset Last-Modified Header set Cache-Control "public,max-age=29030400" #Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" ############################################## # COMPRESSION # ############################################## AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript application/javascript text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html SetOutputFilter DEFLATE #Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
# ================================================================================================================================================================ # MOD_HEADERS CACHING {{{1 # ================================================================================================================================================================ # UNSET DEFAULT SENT HEADERS {{{2 # ---------------------------------------- Header unset Pragma #Header unset ETag #Header unset Cache-Control # SET CACHE_CONTROL HEADER DEFAULT {{{2 # ---------------------------------------- Header set Cache-Control "public,max-age=29030400" # CACHE-SETUP FOR STATIC SITE FILES {{{2 # ---------------------------------------- # UNSET HEADERS {{{3 Header unset P3P Header unset Pragma #Header unset ETag #Header unset Cache-Control #Header unset Expires #Header unset Last-Modified # SET CACHE-CONTROL AND EXPIRES HEADER {{{3 Header set Cache-Control "public,max-age=29030400" #Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT" #}}}3 #}}}2 # ================================================================================================================================================================ # COMPRESSION SETTINGS {{{1 # ================================================================================================================================================================ # AddOutputFilter DEFLATE {{{2 # ---------------------------------------- # The AddOutputFilter directive maps the filename extension extension to the {{{6 # filters which will process responses from the server before they are sent to the client. This is in # addition to any filters defined elsewhere, including SetOutputFilter and AddOutputFilterByType # directive. This mapping is merged over any already in force, overriding any mappings that already # exist for the same extension. }}}6 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html SetOutputFilter DEFLATE #Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" # ================================================================================================================================================================ # MOD_MIME, MOD_NEGOTIATION {{{1 # ================================================================================================================================================================ ############################################################################################################################################################## ### ### MOD_EXPIRES ### ############################################################################################################################################################## # # 2 HOURS ExpiresActive On ExpiresDefault A3600 ExpiresDefault A360000
Now, most of the time I am not an expert. In this case I am not a world-renowned expert, but I'm no punk either.
This goes in your root .htaccess file but if you have access to httpd.conf
that is better.
This code uses the FilesMatch directive and the SetOutputFilter DEFLATE directive to only target files ending in .js
or .css
SetOutputFilter DEFLATE
This goes in your root .htaccess file but if you have access to httpd.conf
that is better.
This code uses the FilesMatch directive and the Header directive to add Future Expires Headers to certain files.
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
This goes in your root .htaccess file but if you have access to httpd.conf
that is better.
This code uses the FilesMatch directive and the Header directive to add Cache-Control Headers to certain files.
# 480 weeks Header set Cache-Control "max-age=290304000, public" # 2 DAYS Header set Cache-Control "max-age=172800, public, must-revalidate" # 2 HOURS Header set Cache-Control "max-age=7200, must-revalidate"
If you are using far Future Expires Headers and Cache-Control (recommended), you can do this for these files.
Header set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
You can use the HTTP Header Viewer Tool to check it.
Header unset Pragma FileETag None Header unset ETag # 1 YEAR Header set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified # 2 HOURS Header set Cache-Control "max-age=7200, must-revalidate" # CACHED FOREVER # MOD_REWRITE TO RENAME EVERY CHANGE Header set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified
This goes in your root .htaccess file but if you have access to httpd.conf
that is better.
This code uses the FileETag and the Header directive to remove all ETags from being sent.
Header unset ETag FileETag None
Please don't turn off ETags and Last-Modified headers for your .html files, leave one of them ON. (I use Last-Modified for .html).
This goes in your root .htaccess file but if you have access to httpd.conf
that is better.
This code uses the FilesMatch directive and the Header directive to remove all Last-Modified
Headers from being sent.
Header unset Last-Modified
By removing both the ETag header and the Last-Modified headers from your static files (images, javascript, css) browsers and caches will not be able to validate the cached version of the file vs. the real version. By also including a Cache-Control
header and Expires
header, you can specify that certain files be cached for a certain period of time, and you magically (this is a really unique trick I promise) eliminate any validation requests!!