Hello everyone!
it's not strictly dragonfly question but a question about dragonfly and sinatra working together. I have a following endpoit in my sinatra app, which basically downloads an image from the URL and applies a "play" png button on top of it. Here is the code:
require 'sinatra'
require 'dragonfly'
require 'rmagick'
require 'rack-cache'
app = Dragonfly[:images].configure_with(:imagemagick)
app.processor.add :play_button do |temp_object, *args|
canvas = Magick::Image.read(temp_object.path).first
append_image = Magick::Image.read('play.png').first
canvas.composite!(append_image, Magick::CenterGravity, Magick::OverCompositeOp)
canvas.to_blob
end
get "/thumb/:url" do |url|
app.fetch_url(url)
.process(:play_button)
.to_response(env)
end
and basically it works prety well. The thing is - it's not using server caching at all, image is being regenerated on each request - which obviously sucks. I'm looking for any solutions on how can i use some third-party (or built-in) mechanism to cache images produced by that endpoint. I know there is a whole section in dragonfly docs dedicated to cacheing but it's not helpfull when it comes down to using it with sinatra.
Maybe that's something obvious - i've just never done such thing before.
Thanks in advance!