Okay, so why were these assets not being cached? A quick check with wget --save-headers revealed that the web server was sending a nocache directive to the browser. This seems to be the default setup for webrick and also for my shared apache hosting on railsplayground. Considering the new rails asset management system with the ?
So, how can we implement no/very long cache expiry? In apache, you can use mod_expires or mod_headers to do this. My shared hosting does not support mod_expires, so I went for mod_headers in my .htaccess file.
<FilesMatch "\.*$"> Header set Cache-Control "max-age=29030400" </FilesMatch>
OR using mod_expires:
ExpiresActive On ExpiresDefault "access plus 1 year"
Either of the the above will set up a cache expiry time of one year for all content (best you only do this for your rails app directories).
With a cache expiry time of one year in place, my rails apps run much much faster.