How to force cache purge of Twitter Card's bots?

后端 未结 4 796
余生分开走
余生分开走 2020-12-24 02:03

Literally I am looking for something like this:

https://developers.facebook.com/tools/debug/

But for Twitter Cards.

I put something wrong on my page

相关标签:
4条回答
  • 2020-12-24 02:24

    Following the steps in Twitter Card's Troubleshooting Guide actually forced the cache to clear in my case.

    When testing and/or iterating on Cards, it is sometimes helpful to test updates on your timeline. It may be possible to use the following technique to refresh the cache with your most up-to-date changes of your page’s Card.

    1. Add Card metadata to a page
    2. Tweet URL to that page
    3. Refresh your browser to view the Card contents on your timeline
    4. Change Card metadata on the page
    5. Take the same URL and runs it through bit.ly
    6. Tweet the new bit.ly URL
    7. Refresh your browser to view the updates

    Additionally, you can create multiple bit.ly URLs to allow for repeat testing.

    I generated a bit.ly link to the page, then tweeted it, and then quickly deleted that tweet. It cleared the cache right away for the other tweet.

    0 讨论(0)
  • 2020-12-24 02:30

    I ran across the same problem.

    I needed to update a cached summary_large_image and the

    Twitter Card Validator (https://cards-dev.twitter.com/validator)

    was showing zero interest in wanting to update the previously cached image.

    I fixed it by ensuring that every time Twitter fetches the page, the image URI updates to something Twitter has never seen or cached before.

    This is as simple as deploying the uniqid() function in PHP and using that as the query at the end of the image URI.

    e.g.

    <?php
    
    echo '
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:image" content="http://example.com/my-twitter-image.png?'.uniqid().'">
    ';
    
    ?>
    

    Since the image URI is different every time Twitter goes to fetch it, this forces the cache to update.

    0 讨论(0)
  • 2020-12-24 02:42

    I just managed to force it to update mine:

    https://cards-dev.twitter.com/validator

    In validating it updates its cache.

    0 讨论(0)
  • 2020-12-24 02:44

    There's actually a simpler solution than what is proposed by Twitter:

    • Go to https://cards-dev.twitter.com/validator
    • Type in the URL you want to update, BUT with a change. For example, add ?utm_source=Whatever
    • Then just reloaded page with whatever tweet had your Twitter card

    When Twitter validator encounters this different URL, it clears its cache and fetches the new version.

    0 讨论(0)
提交回复
热议问题