When a (cached) tweet is deleted on Twitter, my site still displays the cached tweet content but doesn't render it properly. Is this expected?


I cache the html returned from the oEmbed endpoint for tweets. When a (cached) tweet is deleted on Twitter, my site still displays the cached tweet content but doesn’t render it properly. It renders fine otherwise. Is this expected?

Please see this image for a visual explination. http://i.imgur.com/BzjgWJw.png

What information is missing in the HTML returned from oEmbed endpoint that would render it unable to grab all the proper css elements?


When the tweet has been deleted, the tweet is not transformed and displayed just with the HTML returned by the oEmbed endpoint.
Using CSS you can easily make it look closer to normal embedded tweets though.



This is by design: It’s not that embedded Tweets just apply CSS styles to that basic embed code; the content gets completely replaced by a full rendering from our server. Once a Tweet is deleted, we cannot render that version, so the embed code—a simple quote form of the Tweet—is left in place. There’s not really any relationship between the two.

We wanted to ensure that while users can and will delete Tweets, that articles are left with a quality representation of the content and will still make sense to a reader (likewise in situations where JavaScript is typically absent; such as articles in RSS readers.) Likewise, we also wanted to ensure that there is a distinction, lest people be mislead about whether a Tweet was or wanted really posted. All representations of an embedded Tweet have a permalink, so readers can ultimately verify the content of a Tweet by checking the permalink page, of course.

To smooth out the styling differences (while the content format and ordering is still distinct), this documentation might provide you a good starting point: https://dev.twitter.com/docs/tfw/embed-code-css



Thanks to both of you for such prompt and detailed replies. I realise what you mean about the whole thing being rendered on your side and then displayed in an iframe on my end, I had (somehow) never inspected the actual final output of code as a result of a Tweet being embedded until now, and I had never seen the whole iframe

@benward , I understand what you are saying with regards to the balances that are required in situations where JS isn’t present/the tweet has been deleted.

That documentation looks like exactly what I will need to use :slight_smile:

Thanks to both of you again!

EDIT: Just to confirm, by caching the simple HTML returned from the oembed request, is this the proper protocol? I am assuming I can’t store all the rendered iframe data. So I am also assuming every time a page with tweet is loaded it will need to send that request to you to have it rendered, and there is no way to stop this. The only thing I can decrease is the amount of of calls to oembed endpoint. Correct?