I have a view page which has an embedded youtube video on it. I have the proper OG tags so that the video is embedded on facebook when shared.
But in order for above to work, I need to programatically hit the Facebook debugger endpoint so that my url gets cached.
I've created an after_create on my Movie model:
after_create :facebook_cache
def facebook_cache
FacebookCacheUrl.call(Rails.application.routes.url_helpers.movie_url(self))
end
The issue that I'm encountering is that my app is sending Facebook the friendly url, e.g. www.mysite.com/movies/friendly-movie-title
. But at the time the app sends the url, the page is showing a 404. So Facebook is caching the server error page info.
Later in the lifecycle, the url works properly.
My question is where should I be pinging the Facebook debugger so that it happens as soon as possible without leading to a 404?