You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Timothy F." <le...@gmail.com> on 2012/05/01 21:22:45 UTC

[users@httpd] Rails asset pipeline

I've submitted a pull request to the rails guide to request a specific
configuration for apache to use the so-called "asset pipeline" feature
of Rails 3.1.  The rails app concatenates and compresses javascript
and CSS files, and the rails guide has no method of apache config.
Before accepting the pull request, the guide's owner would like peer
review on the apache mailing list of the config, to ensure it is
stable, and a best practice.


The last line of
http://guides.rubyonrails.org/asset_pipeline.html#server-configuration
states:
"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.)"


My pull request can be viewed here:
https://github.com/lifo/docrails/pull/80


Would anybody be able to take a look at the request and provide feedback?

This is the end result of the config on my server:


AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz

# Set rewrite engine to check if the client can accept gzip files
# and a gzipped copy of the requested file exists.
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.gz -f
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>

<LocationMatch "^/assets/.*$">
  # Some browsers still send conditional-GET requests if there's a
  # Last-Modified header or an ETag header even if they haven't
  # reached the expiry date sent in the Expires header.
  Header unset ETag
  Header unset Last-Modified
  FileETag None
  # RFC says only cache for 1 year
  ExpiresActive On
  ExpiresDefault "access plus 1 year"
</LocationMatch>


source reference:
http://www.cravediy.com/59-Simple-gzip-Support-for-Apache-with-mod_rewrite.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org