# Upload this file to the root directory of your project, and rename it to .htaccess # To remove any line - to "comment it out" - place the '#' character at the beginning (as on this line) # To reinstate any line - to "uncomment" it - remove the '#' character from the beginning # This file only contains directives that pertain to performance # pass the default character set AddType 'text/html; charset=UTF-8' html AddDefaultCharset utf-8 # Don't show directory listings for URLs which map to a directory. Options -Indexes # Follow symbolic links in this directory. Options +FollowSymLinks # Prevents problems on localhost: # Eliminates "Negotiation: discovered file(s) matching request: ... (None could be negotiated)" errors Options -MultiViews # Per Page Speed recommendation "Enable gzip compression" (YSlow "Compress components with gzip") AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE image/svg+xml # Requires mod_expires to be enabled. # Enable expirations. ExpiresActive On # Per Page Speed recommendation "Leverage browser caching" (YSlow "Add Expires headers") # Expire images, CSS, JS in 31536000 seconds (1 year), per GTMetrix recommendations ExpiresByType image/x-icon "access plus 31536000 seconds" ExpiresByType image/jpeg "access plus 31536000 seconds" ExpiresByType image/png "access plus 31536000 seconds" ExpiresByType image/gif "access plus 31536000 seconds" ExpiresByType application/x-shockwave-flash "access plus 31536000 seconds" ExpiresByType text/css "access plus 31536000 seconds" ExpiresByType text/javascript "access plus 31536000 seconds" ExpiresByType application/x-javascript "access plus 31536000 seconds" # Expire HTML in 10 minutes ExpiresByType text/html "access plus 600 seconds" ExpiresByType application/xhtml+xml "access plus 600 seconds" # Cache all other files for 2 weeks after access (A). ExpiresDefault A1209600 # Various rewrite rules. RewriteEngine on # Performance (may not be controllable via .htaccess) Header set Connection keep-alive # Serve gzip compressed CSS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.css $1\.css\.gz [QSA] # Serve gzip compressed JS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.js $1\.js\.gz [QSA] # Serve correct content types, and prevent mod_deflate double gzip. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1] # Ensure IE receives correct 'X-UA-Compatible' header # Can be served in HTML, but it causes validation errors BrowserMatch MSIE ie Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie # Serve correct encoding type. Header set Content-Encoding gzip # Header append Content-Encoding gzip # Force proxies to cache gzipped & non-gzipped css/js files separately. Header append Vary Accept-Encoding # Cache control, per PageSpeed recommendations Header set Cache-Control "max-age=2692000, public" Header set Cache-Control "max-age=2692000, public" # Needed for css files to work when stored on a CDN # This eases the restriction on the same origin policy # Only uncomment if you know what you're doing, as it has security implications # Header set Access-Control-Allow-Origin "*" Header set Cache-Control "max-age=2692000, private" Header set Cache-Control "max-age=600, private, must-revalidate" Header append Vary: Accept-Encoding # Uncomment "FileETag none" if PageSpeed/YSlow recommend it # FileETag none # Recent research suggests unsetting these attributes is wrong, so they're commented out # Header unset ETag # Header unset Last-Modified