Twitter card image only showing after sending to validator

We have implemented a bot for discourse that sends a tweet when a new topic is created on our forum. It sends in the form of Twitter Card. It arrives correctly and it’s shown perfectly on the timeline.

The issue is that for most of the tweets, the image is not shown until is passed by the card validator ( )

There are plenty of examples on our timeline (TheCháchara (@thechacharaforo) | Twitter) just look for any tweet card with out logo:

And use the underlying URL on the validator:

And now, after I’ve ping’d the validator, the timeline shows correctly: TheCháchara on Twitter: "" (Sorry I can’t post more than 2 images.)

Is there a way to do this automatically?
Furthermore: Why is this happening?


Ps: This topic was also open on Twitter Developers Forum, but still no luck :pensive:

I suspect the issue is that we add the topic image metadata in a background job, which runs a few seconds after a topic is created (depending on the load of your forum). If twitter fetches and caches the metadata before we’ve generated the metadata, then it will be caching the old information.

When you run it through their testing tool, it resets their cache, and so it starts working.

To work around it, could you add a delay to your bot? 1-2 minutes should be pretty safe.



Thanks for the tip @david. I’ll implement it right now, and will let you know.

It worked like a charm!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.