On Jul 12, 2010, at 2:17 AM, logicaltext wrote:

> That's great, but what if we want to use [Rack::StaticCache][2] (via
> the rack-contrib project) to cache static assets for more than 12
> hours? Does Heroku allow this?

I've just been through this, and I've been meaning to write it up:

The main problem is that the Heroku Rack stack includes (included?) a 
Heroku::StaticAssetsMiddleware that hard-resets the Cache-Control header on any 
Rack::File to 'public, max-age=43200'.

I've worked around this by monkey-patching it to do nothing:
http://gist.github.com/472140#file_static_assets_middleware.rb


I'm additionally writing a cache-busting string into each asset file name, 
rather than relying on the query string. (Prompted by reading through 
http://github.com/eliotsykes/asset_fingerprint.)

But, doing so, I've seen some Weird Behavior that I don't quite understand. 
It's almost as though Heroku recently introduced some Rack::StaticCache's of 
their own.*

The workaround has been to avoid serving files from the standard asset paths. 
I've prepended /assets to all static asset paths and /dynamic for 
sass-generated stylesheets.†

I'm using Rails 2.3.8. Most of the code for this has gone into monkey-patches 
(I know) on ActionView::Helpers::AssetTagHelper, with the Rack::StaticCache's 
set up in config/environment.rb: http://gist.github.com/472140.


All the best,  -- Matthew



[*] Perhaps these have superseded the Heroku::StaticAssetsMiddleware entirely?
[†] These names aren't parallel. I need to fix that. But /app/assets fits in so 
much more nicely than /app/static, don't you think?

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to