I have a Rails 3 application that needs to display images from another application. Those images change over time, so I have a task that runs hourly to check for changes. For performance reasons, I want to create a sprite with those images that I serve from my own application (so 1 image and 1 css file).
Ideally, I’d like Sprockets to handle these files in the same way it does any of my other images and stylesheets in my application so I don’t have to roll my own minification, gzip, caching, etc solutions.
Is there a way to hook into Sprockets at runtime so that I don’t have to stop my server, precompile, and start the server again?
I was unable to find any way to hook into sprockets.
For those who are curious, I solved this problem in the following way (but left out the minification/gzip piece, since the tiny performance boost doesn’t justify the complexity):
The clustering is actually the most difficult piece. The key there is avoiding the case where one server requests the new file but the server that handles that request doesn’t actually have that file yet.