Topic: fragment caching questions

Hi all,

I've got a mini CMS-like system that displays pages from a db. I want to implement caching and I think fragment caching to be best as the other parts of the page depend on who is logged in.

I've setup fragment caching following the tutorials at … ial-part-2

The problem is, it never seems to cache anything. I've checked every path that rails might conceivably be storing the cached pages but nothing appears.

According to the development log my fragment is being cached, however I'm really not sure as I can't see anything being created:

Rendering template within layouts/default
Rendering pages/index
Cached fragment hit: views/

Using read_fragment in the controller it does skip performing the SQL queries so it seems something is happening right. I'm just not convinced until I can see the files being generated.

Can anyone give me a hint what is going on with the caching? BTW I'm using rails-2.1.0.

Thanks for any advice.


Re: fragment caching questions

Right, I've had a fiddle and if I set

config.action_controller.cache_store = :file_store, RAILS_ROOT+"/tmp/cache/"

Then i can actually find the cached files and it does seem to be working just fine.

Re: fragment caching questions

Caching doesn't happen in development by default. Check config/environments/development.rb to enable it.

Re: fragment caching questions

Actually I had enabled caching for development mode so I could get it working before deployment. The problem was that by default it was saving the .cache files to a location I have not been able to determine.

Configuring the cache directory manually everything seems to be working just fine now smile

Re: fragment caching questions

If, by chance, your developing in TextMate hit Apple + T to search in the project. Type in .cache and see if anything comes up. You have probably tried this, or aren't using TM, but it was worth a try smile