Satya's blog - Rails, everything is not the web

Dec 27 2009 17:00 Rails, everything is not the web

Suppose you you Rails fragment caching. Fast and easy right? Now you have a model method which you call from cron to update your data. So you want to expire those fragments from cache. Well, according to this stackoverflow.com post it's next to impossible to cause the cached data to expire without breaking MVC. Solutions/workarounds involve instantiating controller objects or calling a controller method via HTTP. Rails Fail. Some things do NOT need to run via HTTP.

Either that, or I'm doing the wrong after_update method.

Or, it's a permissions issue. (Hint: this is the correct answer. after_update was being triggered but couldn't delete the cache files in /tmp.)

The point stands, though: advising people to muck with the controller, for a cron job to expire cached data, is wrong.

Tag: rails rant