Search code examples
.htaccessmod-deflatemod-expires

.htaccess for compression, browser caching, proxy caching, etc


Can someone provide me with an optimize .htaccess configuration that handles compression, browser caching, proxy caching, etc. for a typical website?

Aside from my visitors, I'm also trying to make Google PageSpeed happy.


Solution

  • I have the following in a yslow_optimizations.conf file I include into my apache conf files, I think they should work Ok in an .htaccess file too:

    # disable ETags                                                                            
    FileETag none                                                                                       
    
    # GZip css, js                                                                                      
    AddOutputFilterByType DEFLATE text/css application/javascript application/x-javascript              
    
    # set expires into the future                                                                       
    ExpiresActive on                                                                                    
    ExpiresDefault "access plus 1 month"                                                                
    

    There's more that could be added to it I'm sure, but it's a start.