Using Apache to Compress HTML,CSS & Javascript

Just a quick tip that I've come across recently, add this to your .htaccess file and if your server supports gzip compression HTML, CSS and Javascript will be automatically compressed.

# compress types
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Not sure if the browser uses a cached version on subsequent requests so this technique may not be suitable for everything.

Posted on 8th September 2010
6 years, 10 months, 2 weeks, 3 days ago

comments powered by Disqus