I''m writing an app that does a lot of data visualization using RMagick. Most of the pages in my app are pretty basic with a few textual descriptions of the data and then a bunch of img tags linking to other actions that render the graphs and use send_data to send the images to the client. Most of the data we work with gets uploaded via an import script each night so the pages and graphs are basically static throughout the day when all of our users are hitting the page. I''d like to cache the generated images server side and then use standard rails sweepers to invalidate it when the import script (which uses all our standard models) runs. It seems that caches_action and caches_page do not work when no view is actually rendered (i.e. send_data is used to send the response.) I''ve done a fair amount of Googling and haven''t found anything about this yet, but I thought it would be worth a post here to see if anyone knew of a clean easy way to do this. Thanks in advance, Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You know, it probably wouldn''t be *that* difficult to do this yourself. Instead of calling send_data directly, make some helper called "render_graph" which does something like if cached_file_exists send_data "cached_file" else generate_chart # generate chart and render to cache end I''m trying to implement this right now with some PDFs I''m generating on the fly. In my case I know the name of the file, so it''s basically serve it, and if you don''t find it, generate it. I know that doesn''t help much, but I know of no existing solutions to this problem. On Mon, Jun 30, 2008 at 2:58 PM, Mike Deck <mikedeck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m writing an app that does a lot of data visualization using > RMagick. Most of the pages in my app are pretty basic with a few > textual descriptions of the data and then a bunch of img tags linking > to other actions that render the graphs and use send_data to send the > images to the client. > > Most of the data we work with gets uploaded via an import script each > night so the pages and graphs are basically static throughout the day > when all of our users are hitting the page. I''d like to cache the > generated images server side and then use standard rails sweepers to > invalidate it when the import script (which uses all our standard > models) runs. > > It seems that caches_action and caches_page do not work when no view > is actually rendered (i.e. send_data is used to send the response.) > I''ve done a fair amount of Googling and haven''t found anything about > this yet, but I thought it would be worth a post here to see if anyone > knew of a clean easy way to do this. > > > Thanks in advance, > Mike > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think you''re right. I''m going to just bite the bullet and write my own. Maybe I''ll even turn it into a plugin... Thanks for the response. On Jun 30, 3:10 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You know, it probably wouldn''t be *that* difficult to do this yourself. > Instead of calling send_data directly, make some helper called > "render_graph" which does something like > > if cached_file_exists > send_data "cached_file" > else > generate_chart # generate chart and render to cache > end > > I''m trying to implement this right now with some PDFs I''m generating on the > fly. In my case I know the name of the file, so it''s basically serve it, and > if you don''t find it, generate it. > > I know that doesn''t help much, but I know of no existing solutions to this > problem. > > On Mon, Jun 30, 2008 at 2:58 PM, Mike Deck <miked...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m writing an app that does a lot of data visualization using > > RMagick. Most of the pages in my app are pretty basic with a few > > textual descriptions of the data and then a bunch of img tags linking > > to other actions that render the graphs and use send_data to send the > > images to the client. > > > Most of the data we work with gets uploaded via an import script each > > night so the pages and graphs are basically static throughout the day > > when all of our users are hitting the page. I''d like to cache the > > generated images server side and then use standard rails sweepers to > > invalidate it when the import script (which uses all our standard > > models) runs. > > > It seems that caches_action and caches_page do not work when no view > > is actually rendered (i.e. send_data is used to send the response.) > > I''ve done a fair amount of Googling and haven''t found anything about > > this yet, but I thought it would be worth a post here to see if anyone > > knew of a clean easy way to do this. > > > Thanks in advance, > > Mike--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---