I load my images, and the first times it will run convert
on them, so it's a little slow.
But I expected it to never run convert
on them again but DragonFly does it over and over again (in development mode).
2014-01-15 14:10:45.587 [fyi] Started GET "/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg" for 127.0.0.1 at 2014-01-15 14:10:45 -0500 (pid:73447)
2014-01-15 14:10:47.149 [meh] DRAGONFLY: shell command: 'convert' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-1ti4jze' '-resize' '920x920>' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-fvdfam.jpg' (pid:73447)
2014-01-15 14:10:47.700 [meh] DRAGONFLY: shell command: 'convert' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-fvdfam.jpg' '-quality' '40' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-e10r7h.jpg' (pid:73447)
2014-01-15 14:10:47.804 [fyi] DRAGONFLY: GET /media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg 200 (pid:73447)
2014-01-15 14:10:47.807 [meh] Cache write: d857888f4b9a786a815372039d952e203c056795 (pid:73447)
2014-01-15 14:10:47.825 [meh] Cache read: d857888f4b9a786a815372039d952e203c056795 (pid:73447)
2014-01-15 14:10:47.826 [meh] Cache read: http://localhost:3000/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg? (pid:73447)
2014-01-15 14:10:47.827 [meh] Cache write: http://localhost:3000/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg? (pid:73447)
But for every request it will convert the images again, any idea why?
PS: My dragonfly.rb
The actual solution is to enable Rack Cache (in
config/environments/development.rb
):And to be conscious that every
image.width
,image.height
, etc... will actually call aconvert
command. So if you want to have this info often, it's better to store it along your model:And in your model: