Facebook Open Graph not clearing cache

2019-01-02 19:23发布

I'm having troubles with my meta tags with Open Graph. It seems as though Facebook is caching old values of my meta tags. Old values for Attributes og:title and og:url are still used, even though I have changed them already.

I ran Lint on a page in my site, and this appeared:

Facebook Open Graph lint screenshot

Notice that there are two values for og:title and og:url, and the last one prevailed. However, The last two entries are the OLD entries that I used for this site. I am now currently using these meta tags (you can verify if you view the source of the HTML):

<meta property="og:title" content="Smart og rummelig pusletaske fra Petit Amour med god plads til alt &#8211; værdi 1.099 kr &#8211; køb nu kun 599 kr   "/>
<meta property="og:description" content="Pinq.dk - Det gode liv for det halve"/>
<meta property="og:type" content="product"/>
<meta property="og:url" content="http://pinq.dk/tilbud/landsdaekkende/lissy/"/>
<meta property="og:image" content="http://pinq.dk/wp-content/themes/pinq/images/logo-top.png"/>
<meta property="og:site_name" content="Pinq" />
<meta property="fb:app_id" content="161840830532004" />

Why is Facebook caching og:title and og:url? Is anyone experiencing the same issue?

19条回答
明月照影归
2楼-- · 2019-01-02 19:35

I was having this issue too. The scraper shows the right information, but the share url was still populated with old data.

The way I got around this was to use the feed method, instead of share, and then populate the data manually (which isn't exposed with the share method)

Something like this:

shareToFB = () => {
    window.FB.ui({
    method: 'feed',
    link: `signup.yourdomain.com/?referrer=${this.props.subscriber.sid}`,
    name: 'THIS WILL OVERRIDE OG:TITLE TAG',
    description: 'THIS WILL OVERRIDE OG:DESCRIPTION TAG',
    caption: 'THIS WILL OVERRIDE THE OG:URL TAG'
  });
};
查看更多
萌妹纸的霸气范
3楼-- · 2019-01-02 19:40

If you have many pages and don't want to refresh them manually - you can do it automatically.

Lets say you have user profile page with photo:

$url = 'http://'.$_SERVER['HTTP_HOST'].'/'.$user_profile;
$user_photo = 'http://'.$_SERVER['HTTP_HOST'].'/'.$user_photo;

<meta property="og:url" content="<?php echo $url; ?>"/>
<meta property="og:image" content="<?php echo $user_photo; ?>"

Just add this to your page:

// with jQuery
$.post(
    'https://graph.facebook.com',
    {
        id: '<?php echo $url; ?>',
        scrape: true
    },
    function(response){
        console.log(response);
    }
);

// with "vanilla" javascript
var fbxhr = new XMLHttpRequest();
fbxhr.open("POST", "https://graph.facebook.com", true);
fbxhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
fbxhr.send("id=<?php echo $url; ?>&scrape=true");

This will refresh Facebook cache. If you use the jQuery solution, have a look at "response" in console.log - you will find there "updated_time" field and other useful information.

查看更多
荒废的爱情
4楼-- · 2019-01-02 19:40
  1. Visit the FB page https://developers.facebook.com/tools/debug/og/object/
  2. Enter your domain.
  3. Click the button "Fetch new scrape information"
  4. Done
查看更多
ら面具成の殇う
5楼-- · 2019-01-02 19:41

I've found out that if your image is 72dpi it will give you the image size error. Use 96dpi instead. Hope this helps.

查看更多
千与千寻千般痛.
6楼-- · 2019-01-02 19:42
  1. Go to http://developers.facebook.com/tools/debug
  2. Enter the URL following by fbrefresh=CAN_BE_ANYTHING

Examples:

  1. http://www.example.com?fbrefresh=CAN_BE_ANYTHING
  2. http://www.example.com?postid=1234&fbrefresh=CAN_BE_ANYTHING
  3. OR visit: http://developers.facebook.com/tools/debug/og/object?q=http://www.example.com/?p=3568&fbrefresh=89127348912

I was having the same issue last night, and I got this solution from some website.

Facebook saves your cache thumbnail. It won't refresh even if you delete the thumnail/image from your server. But Facebook allows you to refresh by using fbrefresh

I hope this helps.

查看更多
浮光初槿花落
7楼-- · 2019-01-02 19:45

The most voted question is quite outdated:

These are the only 2 options that should be used as of November 2014:

For non developers

  1. Use the FB Debugger: https://developers.facebook.com/tools/debug/og/object
  2. Paste the url you want to recache. (Make sure you use the same url included on your og:url tag)
  3. Click the Fetch Scrape information again Button

For Developers

  1. Make a GET call programmatically to this URL: https://graph.facebook.com/?id=[YOUR_URL_HERE]&scrape=true (see: https://developers.facebook.com/docs/games_payments/takingpayments#scraping)
  2. Make sure the og:url tag included on the head on that page matches with the one you are passing.
  3. you can even parse the json response to get the number of shares of that URL.

Additional Info About Updating Images

  • If the og:image URL remains the same but the image has actually changed it won't be updated nor recached by Facebook scrapers even doing the above. (even passing a ?last_update=[TIMESTAMP] at the end of the image url didn't work for me).
  • The only effective workaround for me has been to assign a new name to the image.

Note regarding image or video updates on previously posted posts:

  • When you call the debugger to scrap changes on your og:tags of your page, all previous Facebook shares of that URL will still show the old image/video. There is no way to update all previous posts and it's this way by design for security reasons. Otherwise, someone would be able to pretend that a user shared something that he/she actually didn't.
查看更多
登录 后发表回答