Rails, Mongrel & Pound / SSL and Browser Caching

This may not exactly be a Rails question, but I think this is the most
likely place to find someone with an answer.

We’ve got a Rails site that uses several mongrels and pound as the
balancer between them. The site uses SSL encryption.

The problem is, with the SSL, browsers aren’t caching anything… so
every page view is reloading all the /public/stylesheets and
/public/javascripts. There’s a very noticeable speed difference when we
access the site over a non-encrypted connection. According to DHH’s
comment here… (
http://www.chadfowler.com/2007/2/18/edge-rails-goody-distributed-asset-hosts
) “Browsers actually cache assets just fine on SSL if you set the proper
headers (which most web servers will do by default).”

Well, I’ve looked at the response headers in my browser, and they’re
definitely not being set by default. There’s no difference between the
headers for the same file across http and https (neither of which have
anything like Cache-Control or Expires headers). My understanding is
that, without these headers, browsers will cache non-encrypted stuff for
a day or so (depending on the browser), but will not cache https
retrieved files.

So, my question is, where/how can I best set the response headers so
that the browsers know they can safely cache stylesheets, javascripts,
and images from this app, but not the controller actions. Is this a
mongrel setting, pound setting, something I can set in environemnt.rb?
I’ve scoured the google and I’m not finding any real answers, only hints
(like the one above) that there are answers out there, somewhere.


http://www.5valleys.com/