Speed up Rails controller speed easily
When we adding a Rails controller action, especially for #show
. Usually it would be like this:
It would hit our database everytime there is a request to that action. So what we can do is we cache the Post model into Cachestore.
Usually I use identity_cache gem for that. It uses Memcached as a datastore. So it would be like this if using IdentityCache gem:
Another optimization is we can add expiry tag
See more about IdentityCache at: https://github.com/Shopify/identity_cache
Leave a comment