views:

156

answers:

1

Hi,

I want to use rails page caching to speed up a application which encounters heavy load. But I also need to count the hits/views on the objects presented. So I have the model "Article" with a unique hit counter method (by IP) which is called every time the user hits the show action. That doesn't work with caching, so I'm wondering about the right way to solve this problem. There is no need for the counter to show real-time results.

Thoughts so far:

  • Use Cron and a Rake task to analyze the log/production.log file
  • Write to a custom log (how? using nginx)

Thanks for any input, ideas or best practice examples!

+1  A: 

Custom logging is pretty simple with nginx. Have a look at the logging module wiki.

I'd just use that (or parse the default) on a cron job and go from there.

Oli