Ask A Question

Notifications

You’re not receiving notifications from this thread.

GoRails Screencast suggestion: Caching

Sascha M. asked in Site Feedback

Hi there,

just a quick suggestion. I'm at a stage where I'm struggling with Caching. Since you haven't covered this topic yet I would be very happy if you do, especially Database query caching.

Greetings!

Reply

I do have an episode on Fragment caching that is helpful: https://gorails.com/episodes/fragment-caching-and-oembed

The main reason I probably won't cover query caching is because in order for your website to be always up-to-date, you'll have to query the database to find the most recent records. If you cache queries, you won't know that there are new records since you didn't make another query.

The way fragment caching helps is you make the query (which only takes a couple milliseconds) and then you look at the results to see if there are HTML fragments cached for those results. If so, you just send over the HTML fragment as a response instead. This is a lot simpler and gives you the same benefit in performance.

Reply

Thanks for that. I'll give it a try.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.