Skip to main content

Join GoRails to continue learning

Subscribe to GoRails to get access to this episode and all other pro episodes, and new awesome content every month.

Subscribe Now
Only $19/month

Login to your account

16 Improve Performance With Caching:

Fragment Caching And oEmbed

Episode 40 · January 23, 2015

Learn how oEmbed works to dynamically grab embed codes from a URL and how we can use fragment caching to make this more efficient

Frontend Javascript


Subscribe or login to view the transcript for this episode.



Really great episode, I will be implementing something similar soon. While watching I had a question: Could the first-time-slow-page be avoided by making a rake task to visit all video pages using something like httparty, watir, mechanize, or something similar? We have a little over 200 videos on our site, so this would be nice to avoid the delay every day/week/whatever we set the cache length.


You could remove the expires_in option and set up a nightly cron job to expire the fragments and then immediately request the page instead. When you do it with an expiration like this, you can't know when it expires exactly so it would be hard to expire and then request the page again.


Even better, syncing those two, expiration and cache, was bothering me. Thanks Chris!

Login or create an account to join the conversation.