Skip to content

Instantly share code, notes, and snippets.

@handrus
Created May 21, 2013 16:15
Show Gist options
  • Save handrus/5621058 to your computer and use it in GitHub Desktop.
Save handrus/5621058 to your computer and use it in GitHub Desktop.
htacess tuned for better performance. Tested with yslow and pagespeed
<IfModule mod_expires.c>
# Enable the module
ExpiresActive On
# Default expiration of 2 weeks
ExpiresDefault A1209600
# Expire CSS, JS and images content after 1 day.
ExpiresByType text/css "access plus 1 day"
ExpiresBytype text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
#Expires flash after 1 week
ExpiresByType application/x-shockwave-flash "access plus 1 week"
</IfModule>
#You must take care to make this decision of remove Etags,
# in webservices this can be usefull!
<ifModule mod_headers.c>
#<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
# Header unset ETag
# FileETag None
#</FilesMatch>
Header unset ETag
</ifModule>
FileETag None
# BEGIN Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|iso|tar|bz2|sit|rar|png|jpg|gif|jpeg|flv|swf)$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.[0678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48, the above regex won't work. You can use the following
# workaround (comment the above line and uncomment the below line) to get the desired effect:
# BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
#END Gzip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment