aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorleprasmurf <leprasmurf@gmail.com>2012-01-23 14:13:33 -0500
committerleprasmurf <leprasmurf@gmail.com>2012-01-23 14:13:33 -0500
commitfce92fd8a7e407b034d189a652af81a06ac98730 (patch)
tree7a02427ad25095580f00bfc4ff0c5b43a9153d61
parent2bcfdec227077a7e693056e2a79470163402c2d5 (diff)
downloadrails-fce92fd8a7e407b034d189a652af81a06ac98730.tar.gz
rails-fce92fd8a7e407b034d189a652af81a06ac98730.tar.bz2
rails-fce92fd8a7e407b034d189a652af81a06ac98730.zip
Added Apache configuration for dynamic gzip content
-rw-r--r--railties/guides/source/asset_pipeline.textile25
1 files changed, 24 insertions, 1 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile
index ff2bd08602..f6e56ed529 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/railties/guides/source/asset_pipeline.textile
@@ -505,7 +505,30 @@ This directive is available if the core module that provides this feature was co
If you're compiling nginx with Phusion Passenger you'll need to pass that option when prompted.
-A robust configuration for Apache is possible but tricky; please Google around. (Or help update this Guide if you have a good example configuration for Apache.)
+For Apache:
+
+Using the Apache config tricks found on the Crave DIY blog, the following rewrite rules check the client's header to see if gzip is supported, then checks the filesystem to ensure a gzipped version exists, finally serving the gzipped file and forcing a the appropriate type.
+
+<plain>
+# Turn on the Rewrite engine
+RewriteEngine On
+# Check the client headers to see if they accept gzips
+RewriteCond %{HTTP:Accept-Encoding} gzip
+# Confirm the file exists in gzip format
+RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.gz -f
+# Rewrite url to us gzip file
+RewriteRule (.*\.(js|css))$ $1\.gz [L]
+
+# If we've rewritten to a .css.gz file, force text/css
+<FilesMatch .*\.css.gz>
+ ForceType text/css
+</FilesMatch>
+
+# If we've rewritten to a .js.gz file, force application/x-javascript
+<FilesMatch .*\.js.gz>
+ ForceType application/x-javascript
+</FilesMatch>
+</plain>
h4. Live Compilation