templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf in rubber-2.0.0.pre1 vs templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf in rubber-2.0.0.pre2
- old
+ new
@@ -1,8 +1,8 @@
<%
@path = "/etc/apache2/sites-available/#{rubber_env.app_name}-passenger"
- @post = "a2enmod rewrite && a2enmod ssl && a2ensite #{rubber_env.app_name}-passenger"
+ @post = "a2enmod rewrite && a2enmod ssl && a2enmod expires && a2enmod xsendfile && a2ensite #{rubber_env.app_name}-passenger"
%>
<% [rubber_env.passenger_listen_port, rubber_env.passenger_listen_ssl_port].each do |port| %>
Listen <%= port %>
@@ -18,18 +18,54 @@
SetEnvIf User-Agent "^(.*MSIE.*)|(.*AppleWebKit.*)$" nokeepalive
RailsEnv <%= Rubber.env %>
+ XSendFile on
+
RewriteEngine On
RewriteCond %{HTTP_HOST} ^<%= rubber_env.domain %>$
RewriteRule ^(.*)$ http://www.<%= rubber_env.domain %>$1 [R,L]
# Include <%= Rubber.root %>/config/apache/rewrites.conf
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
+
+ <% if Rubber::Util.has_asset_pipeline? %>
+ <LocationMatch "^/assets/.*$">
+ Header unset ETag
+ FileETag None
+
+ # RFC says only cache for 1 year.
+ ExpiresActive On
+ ExpiresDefault "access plus 1 year"
+
+ # Cache the resource even if SSL is in use.
+ Header merge Cache-Control public
+
+ SetEnv no-gzip
+ </LocationMatch>
+
+ # Serve the gzip'd assets directly from disk if they were generated by Sprockets.
+ # This avoids gzipping the asset on the fly by Apache and Sprockets will usually use a higher level
+ # of compression than mod_deflate will, yielding savings all around.
+
+ RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
+ RewriteCond <%= Rubber.root + "/public" %>%{REQUEST_FILENAME}.gz -s
+ RewriteRule ^(.+) $1.gz [L]
+
+ <FilesMatch \.css\.gz$>
+ ForceType text/css
+ Header set Content-Encoding gzip
+ </FilesMatch>
+
+ <FilesMatch \.js\.gz$>
+ ForceType text/javascript
+ Header set Content-Encoding gzip
+ </FilesMatch>
+ <% end %>
<% if port == rubber_env.passenger_listen_ssl_port %>
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem