Topic: Am I using fragment caching correctly?

My app has a 'show' page which shows a place with its associated user reviews. Some calculations are done on the page (to average some review stats), and it is not uncommon for the page to take 4-5 secs to load (I'm still working on optimizations, but I don't know how much further I can go).

I was inspired by Ryan's recent Railscast on fragment caching, so I put a <% cache do %> around the calculations and user reviews, and of course I have to refresh the cache each time a user leaves a new review.

In the Railscast, Ryan frowned upon having a different cache file for every place id (show/1, show/2, show/3, and so forth...). But I don't see any other way for me to do it, since every place will have different reviews and stats. Is it a bad idea for me to be caching this way? Or am I getting scared for no reason?

Re: Am I using fragment caching correctly?

You mis-understood what Ryan was saying.  The fragment he was caching was the same for every show action, but it was getting cached on each page as a different file.  Adding in the string value to the cache do was so that it would cache once and then load the same file in every show action.

Your case is different, as each fragment does not share the same data.  So it will need to be cached once for each show action.

Last edited by ericc59 (2008-01-31 19:29:48)