Fragment Cacheing and Cache Keys
Not that the following happened to me or anything...
So, you use Ruby on Rails. And you have a particularly slow partial that gets called on all the time. No problemo right? Let's just wrap that guy in some cacheing and move on. You do something like this:
https://gist.github.com/4984376
Great, your site is now running way faster. Now it's time to update that partial. Boom, update the partial! Wait... My site looks exactly the same. Okay, obviously cache takes two hashes. That code really should have looked like this:
https://gist.github.com/4984428
Lesson learned, I'll just fix that right up and... Right, that partial is getting hit all the time, that's why you put it in the cache to begin with. So it's definitely not falling out of cache. Alright, "how do I fix this"?
So, first thing, I guess you try using expire_fragment in the console, but of course this all depends on the scope it's called in so that's not working out. What to do? What to do? Well, let me tell you, you have come to the right place.
Do this in the console: (Thank me later.)
https://gist.github.com/joeljackson/4984474
Of course if you just want to expire the fragment and you didn't do the stupid expires in thing, just ditch that at the end.
Cheers!!
Joel












