Rails 3 Asset Pipeline + Apache + Phusion Passenger Rails 3 Asset Pipeline + Apache + Phusion Passenger apache apache

Rails 3 Asset Pipeline + Apache + Phusion Passenger


If you want the full benefits of the asset pipeline, you do, indeed, need to add this to your Apache configs. Without that section, your Apache configuration is likely specifically telling browsers not to cache assets - resulting in an unnecessary number of round trips between the browser and your server.

In order to get this to work, you may need to enable a few more Apache modules. To do this:

sudo a2enmod# Choose headerssudo a2enmod# Choose expiressudo service apache2 restart

To debug your set-up, I recommend using the Live Headers Firefox plugin. Using that, specifically request an asset URL (e.g. http://mysite.com/assets/application-8a0ae0b2d708f797674b7123c37501ba.css)and look at the cache headers before and after you make this change. Find an example asset URL by doing a View Source on any page.

After the change, you should see that the cache expiration is set to one year in the future.