Caching Strategy

Highlighted
New Member
24 0 0
I have my app setup to cache some of the product information for a much more responsive experience when using my app. I figure for my needs updating my local cache once a day when the user hits my app should be plenty enough. I don't store every detail about a product just the information my application needs. I have the caching mechanism built into my local models which will update themselves if they notice the cache is out of date. So when I am working with my controllers I dont need to worry about the shopify api I just use my own models. Its pretty neat :) I was just wondering what others have done to cache the data and some of the best approaches to caching data for a better overall user experience. Is everyone else using the shopify api in there own models? Or are most people just using them directly in the controllers like the scaffold application? What would be the best practices when it comes to caching? Just figured i would get a conversation started :)
0 Likes
New Member
24 0 0

I have a question related to my caching process.

So the initial setup of a shopify account on my app takes a little bit of time because of the api calls to shopify. Grabbing the shop information, product information, etc…

The user will experience a delay while the account is cached. Right now I am using a spinner :)

But I think just starting another thread to finish up the initial load would be a better idea. So I could get the shop information setup the account and then transfer the user to an introduction page. Meanwhile in the background the thread is loading their products and other information.

I have looked around the internet a bit about threading in rails and people seem to recommend staying away from threading with activerecord. Problems with the mysql gem not being thread safe causing issues…

Does anyone have a sound strategy for threading with activerecord? Are there any good resources out there to get up to date information about threading and active record?

Or maybe I should just stick with the spinner :) I could just throw up a modal with a game of tetris while they wait :)

0 Likes
Shopify Staff
Shopify Staff
2002 0 41

We do a fair bit of local caching in our own apps. Things like the Shop.current call and even products we tend to store in memcached or the database for future accesses.

You can see this in action with PixelPrinter which we released as open source on GitHub.

We have one API application that has to download the entire product catalog of a store to create a specialized output file for powerreviews. In this app we use a similar strategy to what you describe. After the initial login we spin up a background job to fetch all the products of the store. We use our own DJ plugin for that which is currently the most popular choice for background processing in rails applications. Luckily our friends at Heroku added full support for DJ which makes it a great choice on their platform.

Tobias Lütke - Shopify CEO // http://twitter.com/tobi
0 Likes