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

15 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

Javascript Frontend


Transcripts

Subscribe or login to view the transcript for this episode.

Discussion


Gravatar
Thomas Bush (3,100 XP) on

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.

Gravatar
Chris Oliver (167,500 XP) on

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.

Gravatar
Thomas Bush (3,100 XP) on

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


Login or create an account to join the conversation.