How to manually refresh web page previews in Twitter cards
All of us – or at least those of you who found this page via Google – have probably at some point been in a situation where they tweeted a link to a web page, only then to find out that the link’s preview card contains something that shouldn’t be there, like a screenshot of your private browsing window that you inexplicably managed to make, edit, upload, and publish to your blog by accident.
You quickly try to correct your mistake by replacing the image with something less unsightly, but alas: Twitter has cached the metadata of the web page and now seemingly has decided that the preview for your web page should forever expose your weird private browsing preferences to the entire world.
Fortunately the solution is pretty easy. Twitter has a card validator tool that is primarily intended to validate if a web page contains the right metadata to generate a Twitter card (which is what those previews are officially called). But it also has the handy side effect of invalidating any cached versions of Twitter cards for any web page that you submit to it.
To refresh a Twitter card, open the card validator in a web browser, enter the , and click on “Preview card”. If done correctly, you should see a success message that looks a bit like this one:
Now all you have to do is wait a few minutes until the old Twitter card is completely replaced by the updated version!
Twitter’s card validator doesn’t always work the way you expect it to, especially if the URL in your tweet contains a redirect. Twitter will not only happily follow redirects, but it also seems to use the URL of its final destination page as a cache key.
This means that if you tweeted a link to example.com/pupper
that redirects to
example.com/corgi
, you should invalidate the latter URL (example.com/corgi
)
rather than the link as it appears in the tweet.
Moreover, if you ever modify example.com/pupper
so that it points to another
page (like example.com/husky
) and you want to refresh the Twitter card in that
same tweet, you should still submit the URL that it originally pointed to,
which would be example.com/corgi
!
On the other hand, if you need to invalidate the card for a newer tweet that was
published after the redirect change, you’ll need to submit example.com/husky
,
as that was the final destination URL at the time.