Skip to content

Instantly share code, notes, and snippets.

@SamBenson
Created September 15, 2011 15:52
Show Gist options
  • Save SamBenson/1219630 to your computer and use it in GitHub Desktop.
Save SamBenson/1219630 to your computer and use it in GitHub Desktop.
Our .htaccess boilerplate
ExpiresActive On
RewriteEngine on
RewriteBase /
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
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
# Expires 1 month after file is first accessed
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/plain A2592000
# Expires 1 month after file is modified
ExpiresByType application/x-javascript M2592000
ExpiresByType text/css M2592000
ExpiresByType text/javascript M2592000
ExpiresByType text/html M2592000
@dantuck
Copy link

dantuck commented Sep 15, 2011

Thanks for this. Good to have in the toolbox.

@SamBenson
Copy link
Author

No problem - for new installations don't forget to hit a2enmod expires first!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment