178

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?

freejosh
  • 11,263
  • 4
  • 33
  • 47
Ardee Aram
  • 4,740
  • 8
  • 36
  • 37
  • I suppose this is like a history? I'm seeing FB getting the latest `title` and `url` for you (in the info table) so why bother? – ifaour Apr 25 '11 at 08:29
  • The problem is, the facebook Like count is still for the OLD og:url (http://pinq.dk) which is around 200+, as opposed to counting for http://pinq.dk/tilbud/landsdaekkende/lissy/ – Ardee Aram Apr 25 '11 at 08:33
  • and I don't think this is history. More of og:url being (supposedly) set twice, the last being the one that prevailed. Somehow, old values that are removed already from the code still affect the meta values. – Ardee Aram Apr 25 '11 at 08:35
  • 3
    Well, have a read of [this](http://developers.facebook.com/docs/opengraph/). Especially the **Editing Meta Tags** section. I'm not sure if it's related but it may help. Will check on this later, sorry mate! – ifaour Apr 25 '11 at 08:40
  • 2
    That's probably it. "You can update the attributes of your page by updating your page's tags. Note that og:title and og:type are only editable initially - after your page receives 50 likes the title becomes fixed, and after your page receives 10,000 likes the type becomes fixed. These properties are fixed to avoid surprising users who have liked the page already. Changing the title or type tags after these limits are reached does nothing, your page retains the original title and type.". Thanks ifaour! – Ardee Aram Apr 25 '11 at 08:45
  • Since this is the answer with the most upvotes, will post here the solution (2016): In the URL debugger, go to bottom and click: "Scrape via API". – Mike Gleason jr Couturier Sep 02 '16 at 15:10
  • How do you do that? @MikeGleasonjrCouturier –  Jun 02 '17 at 14:34
  • As of today, none of the existing answers worked for me. –  Jun 02 '17 at 14:34
  • That's my solution, it's working perfectly for me ...: https://stackoverflow.com/questions/6693499/how-can-i-set-a-website-image-that-will-show-as-preview-on-facebook/67014625#67014625 – maPer77 Apr 09 '21 at 03:29
  • That's my solution, it's working perfectly for me ... https://stackoverflow.com/questions/6693499/how-can-i-set-a-website-image-that-will-show-as-preview-on-facebook/67014625#67014625 – maPer77 Apr 09 '21 at 03:31

22 Answers22

310
  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.

starball
  • 20,030
  • 7
  • 43
  • 238
P.C.
  • 3,751
  • 2
  • 18
  • 17
  • 31
    param **fbrefresh** might not be necessary as the debug tool refreshes the object without it. – alexandru.topliceanu Mar 25 '12 at 20:23
  • 7
    It does not clear the cache whatsoever unless you use this parameter. – Umur Kontacı Sep 06 '12 at 23:41
  • 29
    Untrue, adding that parameter makes no difference to the debug tool's operation - there is no reference to that parameter whatsoever in the debug tool or scraper code – Igy Sep 21 '12 at 18:01
  • 7
    There's no need to use the fbrefresh parameter, but you do need to be logged in as an admin for the FB app that owns that domain, otherwise the cache won't be updated. – Felipe Brahm Oct 03 '12 at 21:51
  • Are you sure? is there any reference that say that you have to be logged in as admin to clear facebook cache? – shem Oct 04 '12 at 20:20
  • 2
    with fbrefresh appended you are just giving the object debugger a different url to cache, if you return back to the url in question it's still the same – Question Mark Mar 06 '13 at 12:14
  • 2
    I needed to use the parameter to update my cache, and remember you might need to change it everytime, i.e. ?refresh=1, ?refresh=2, ?refresh=3 etc – Ric Mar 14 '13 at 10:12
  • I just used with ?fbrefresh=99999999 without being an admin at all, and it refreshed. – keo May 23 '13 at 15:13
  • 3
    I can verify that adding the fbrefresh parameter worked for me. If I shared the URL it used old data even though debugger was showing the correct data. But once I used the debugger with fbrefresh parameter then even normal shares used the correct data. – ice cream Aug 18 '13 at 13:53
  • 2
    In my case, it wont refresh cache. I mean for payment products, it still uses cached one.. – Igor Jan 29 '14 at 09:32
  • 1
    It was also my experience that the debug tool did NOT refresh the cached object without using fbrefresh, and DID refresh the data at the original URL after using fbrefresh. This also affected ordinary shares. – greg_1_anderson Mar 08 '14 at 16:39
  • 2
    fbrefresh doesn't work for me, facebook still has an old cache. – Tyguy7 Jun 13 '14 at 23:32
  • 1
    It worked for me, when run explicitly on the shared 'href'-targets. Not sure if admin was required or not. – Manuel Arwed Schmidt Jun 26 '14 at 08:47
  • 2
    did not refresh for me – JinSnow Jun 27 '14 at 06:33
  • This does not work for me. The scraper shows the new information but the sharer still shares the old. Any updates on this? – Peege151 Apr 04 '16 at 07:08
  • 1
    You can also use the "Scrape again" button now which will clear and recache the link: https://developers.facebook.com/tools/debug/sharing/?q=http%3A%2F%2Fwww.google.com – Aron Jan 12 '17 at 18:25
  • Facebook also added a batch cache invalidator recently: https://developers.facebook.com/tools/debug/sharing/batch/ – Aron Jan 12 '17 at 18:26
  • 2
    Adding `?anything` makes it "look" like it works. In reality, testing the regular URL again will give the same old results. –  Jun 02 '17 at 14:36
  • For those using Wordpress: Clear your cache in your caching plugin like W3 Total Cache or Varnish before following these steps. This is the only way it worked for me. – Elliott Davies Jan 14 '18 at 09:29
84

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.
Oriol Esteban
  • 853
  • 7
  • 6
  • It doesn't seem to return the number of shares for my page. I read in this post: "http://stackoverflow.com/questions/3581488/facebook-graph-api-get-id-for-a-url?answertab=votes#tab-top" that you need to have a Facebook like/share button on the page in order for the output of this end-point to contain any information. – St. Jan Feb 17 '15 at 17:24
  • make sure the tags are in the HEAD and not the BODY of your page - the debugger WILL warn you of this and but they'll be ignored (yes I know you mentioned this I just wanted to stress the point) – Simon_Weaver Aug 10 '15 at 17:55
  • @Oriol Esteban did you find other ways for updating images? – Petr Sep 10 '15 at 12:12
  • Solved. I solved it with adding ?t=TIMESTAMP to my image url in php script, where we generate tags. For now it works. – Petr Sep 10 '15 at 12:51
  • Thank you man!! i have spent hours trying to fix this and the issue was the URL I was passing wasnt the same being passed. FB documentation confused me there and I understood the URL attribute had to be the root. +1 for you! – Cynthia Sanchez Sep 22 '15 at 18:16
  • 3
    @Oriol When I recently tried this I had to POST post to this URL (as per https://developers.facebook.com/docs/sharing/opengraph/using-objects#update ) – Glen T Oct 29 '15 at 17:23
  • 1
    Any ideas about how to scratch the cache when changing the url of og:video ????? I did a small edit to my video and changed the url, and facebook keeps showing the old version! I obviously did the scratch in debug (an it shows correctly there) but not in the post! ... this is driving me crazy! – RayOnAir Nov 07 '15 at 15:12
  • @RayOnAir did you just have to wait? I'm experiencing the same thing. – Peege151 Apr 04 '16 at 10:12
  • @Peege151 It seems like Facebook does not scratch the cache for a video associated with a page url. The only way to get around that seems to change the page url. Any past post with the old url will continue to show the original video when played directly on facebook. Changing the url in the og:video tag is not enough. – RayOnAir Apr 04 '16 at 14:01
  • @Peege151 When you call the debugger to scrap changes on your image or video, all previous posts will still show the old video/image. The new scrapped content will only be used for new posts/shares going forward. This is by design and for security reasons. Otherwise I could pretend that you shared something that you didn't. – Oriol Esteban Apr 05 '16 at 11:01
  • @OriolEsteban When I call the debugger it shows the good information, when I click the share button after scraping, it still shows the old information. I'm not talking about updating content that's already been shared. – Peege151 Apr 05 '16 at 17:11
  • @Peege151 I understand. I assume you are using the same url/filename for the new video. I had a similar issue with images. Even with a?v=[newVID] didn't work. If you give your video a new file name it should work. – Oriol Esteban Apr 06 '16 at 20:36
  • Facebook also added a batch cache invalidator recently: https://developers.facebook.com/tools/debug/sharing/batch/ – Aron Jan 12 '17 at 18:25
  • About og:image, from https://developers.facebook.com/docs/sharing/opengraph/using-objects#update : _If you want to update an image for an object, we strongly suggest that the URL to the image be different than the original image URL. Caching may prevent the image from being updated._ Adding a get parameter seems to work for me. – sglessard Aug 08 '17 at 13:25
  • Make sure the og:url tag included on the head on that page matches with the one you are passing. – Wasim A. Jan 25 '18 at 15:13
  • Update: Doesn't seem to work now! I have definitely changed the image. URL is the same. Even changed the file name of the thumbnail image and uploaded again. But no luck! – arunwithasmile Dec 12 '18 at 14:11
19

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.

shawncampbell
  • 888
  • 10
  • 12
Zhorzh Alexandr
  • 1,469
  • 2
  • 17
  • 28
  • this was the only consistent solution that would bust the image cache for me. using `fbrefresh` didn't do anything for my problem. – hellatan Feb 22 '14 at 15:39
  • Hi, I'm trying this method but I'm getting some errors, $this->output(' '); – monsterboy Apr 03 '14 at 10:10
  • I'm getting the following error Uncaught ReferenceError: $ is not defined (anonymous function) any help would be very appreciated :) – monsterboy Apr 03 '14 at 10:11
  • @monsterboy $ - this is a shortcut to jQuery function. $.post() is the same as jQuery.post() To use this library you have to import it first: – Zhorzh Alexandr Apr 08 '14 at 13:51
  • @ZhorzhAlexandr thx for ur answer but i m using wordpress and i have one post which could be edited every day so how i could use this script every time before sharing ? – Antwan Oct 11 '14 at 10:03
  • i have no expirience with wordpress, so tell me please what is your desired behavior of the page? Maybe you can run this script every time your user updates the post? – Zhorzh Alexandr Oct 11 '14 at 19:46
  • @hellatan didnt work for me for some reason. Can you provide some details please? – Petr Sep 10 '15 at 10:53
  • @petr Please describe what exactly are you doing. Do you recieve any response from the https://graph.facebook.com? – Zhorzh Alexandr Sep 10 '15 at 11:01
  • @Zhorzh Alexandr I receive json of my og object, with all correct values. But the images on Facebook are old – Petr Sep 10 '15 at 12:09
  • #petr Please give me your og:url, you can find it in this line: – Zhorzh Alexandr Sep 10 '15 at 12:13
  • I solved it with adding ?t=TIMESTAMP to my image url in php script, where we generate tags. For now it works. – Petr Sep 10 '15 at 12:50
12

The OG thumbnail does not seem to refresh even if passing the fbrefresh variable. To update this without waiting for automated clearing you'll need to change the filename of the thumbnail associated meta tag value and refresh.

Seb
  • 121
  • 1
  • 2
  • According to the other answers, you can force a refresh using the `fbrefresh` URL parameter. – Sam Mussmann Dec 12 '12 at 16:36
  • 1
    @SamMussmann It seems this only (if it even does that) refreshes the cache of the OG tag contents, and NOT the actual image found from the URL of said contents. EG: You keep the OG tags the same, but change the image file (keeping the name the same) and the image itself will stay in cache. I've found no way to clear this apart from, as Seb said, you must change the image filename. – Nick M Oct 02 '14 at 04:03
  • @Nick M Did you find any other solutions? – Petr Sep 10 '15 at 12:13
  • Solved. I solved it with adding ?t=TIMESTAMP to my image url in php script, where we generate tags. For now it works. – Petr Sep 10 '15 at 12:51
  • Just tried renaming image file and updated the meta tag value, not working too. – Antonio Ooi Apr 11 '16 at 06:25
7

I had the same issues using og:image, several attempts to rename the file or clear FB cache did not work either via the facebook debugger or testing via an actual account.

The new facebook guidelines state the image size should be 1200 x 630 or having that aspect ratio, this seems to be wrong, the only thing that worked for me was using an image with square dimensions.

Edit* Afew hours I went back to use 1200 x 630 and it magically worked, it was magical.

I also renamed the files to f*^*kfacebook.jpg, not sure it helped but it felt good.

Wyck
  • 2,023
  • 4
  • 28
  • 34
7

Basically, the answer is patience ;)

I checked the Linter this morning, and og:title and og:url displays correctly, without the redundant values. I guess FaceBook automatically clears its cache at some specific interval. I just have to wait.

enter image description here

Ardee Aram
  • 4,740
  • 8
  • 36
  • 37
  • From [facebook for developers](https://developers.facebook.com/docs/games_payments/takingpayments#scraping), _The object cache expires every 7 days, and Facebook will automatically rescrape the object when it's next used._ – Venugopal Jul 28 '16 at 17:08
4

Ooook, finally it helped (I use IP.Board). What I had to do was:

  1. Change url of og:image on my website (General configuration).
  2. Try this method with ?fbrefresh=1154464gd56

Thanks to author for this thread!

EDIT: What is more you need to remember about image requirements. For now (january 2013) it's: - at least 200 px in both directions - maximum ratio 3:1

Matt
  • 41
  • 2
4
  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
Cropis
  • 280
  • 2
  • 7
4

I'm sorry folks but the correct answer is:

There is no fool proof way to update the open graph og:image url with immediate result. It is cached until fb updates (reportedly every 24 hours)

Here are things that have been reported to work by others but I have had ZERO success with any of them.

  • Choosing "Fetch new scrape information"
  • Changing the actual image filename and/or deleting the original
  • Adding a query string to the image url by appending a PHP TIMESTAMP or ?anything
  • Adding the "...yoursite.com/?fbrefresh=anything" query string to the debugger fetch url
  • Choosing the graph API link at the bottom of the og dev page
  • Choosing to see exactly what the scraper sees - does not appear to request real time un-cached scrape data, it still shows the cached image url even if the file no longer exists

Inspecting your code is always a spot on way to confirm it is not an issue with browser cache or some caching service. If the meta information is up to date in your code and you've tried all of the above (unless another suggestion comes to fruition), the correct answer is you can do nothing but wait.

4

Yes, facebook automatically clears the cache every 24 hours: Actually facebook scrapes the pages and updates the cache every 24 hours https://developers.facebook.com/docs/reference/plugins/like/#scraperinfo.

kbsbng
  • 2,261
  • 2
  • 18
  • 25
3

We just ran into this, as it turns out, we weren't linting the right url, since the real url had a query string (duh, different page as far as a bot is concerned).

http://example.com/

!==

http://example.com/?utm_campaign=foo

The linter will recache your page, you don't have to wait.

Ryan Florence
  • 13,361
  • 9
  • 46
  • 63
3

One thing to add, the url is case sensitive. Note that:

apps.facebook.com/HELLO

is different in the linter's eyes then

apps.facebook.com/hello

Be sure to use the exact site url that was entered in the developer settings for the app. The linter will return the properties otherwise but will not refresh the cache.

Justin
  • 31
  • 1
1

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

Gordon
  • 11
  • 1
1
  1. Go to http://developers.facebook.com/tools/debug

  2. Paste in the url of the page and click debug. If your site is using url aliases make sure you are using the same url as Facebook is using for the page you are sharing (example: in Drupal use the node/* path instead of the alias if the page is shared via that url).

  3. Click in the "Share preview" part on "See this in the share dialog" link
Hans Rossel
  • 211
  • 2
  • 6
1

Facebook Developer Documents says title property has exception:

Once 50 actions (likes, shares and comments) have been associated with an object, you won't be able to update its title

https://developers.facebook.com/docs/sharing/opengraph/using-objects#update

moogoo
  • 381
  • 5
  • 10
0

Had a similar experience. Website link was showing a 404 in the preview that facebook generated. Turns out the og:url metadata was wrong. We had already fixed it a few days back but were still seeing a 404 on the preview. We used the tool at https://developers.facebook.com/tools/debug/ and that forced the refresh (didn't have to append any parameters by the way) In our case, Facebook didn't refresh the cache after 24 hours but the tool helped force it.

jawss510
  • 21
  • 5
0

It is a cache, ofc it refreshes, that's what cache is ment to do once in a while. So waiting will eventually work but sometimes you need to do that faster. Changing the filename works.

Srneczek
  • 2,143
  • 1
  • 22
  • 26
  • So why -1? Literally noone answered the simplest solution to CHANGE THE FILENAME and it actually works not like other (+/- 5) answers voted up which don't or at least they did but are outdated. Ofc if you can't change the filename for some reason, this answer will not help you. – Srneczek Apr 21 '15 at 09:03
0

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'
  });
};
Peege151
  • 1,562
  • 2
  • 21
  • 45
0

Really easy solve. Tested and working. You just need to generate a new url when you update your meta tags. It's as simple as adding a "&cacheBuster=1" to your url. If you change the meta tags, just increment the "&cacheBuster=2"

Orginal URL

www.example.com

URL when og meta tags are updated:

www.example.com?cacheBuster=1

URL when og meta tags are updated again:

www.example.com?cacheBuster=2

Facebook will treat each like a new url and get fresh meta data.

Will
  • 605
  • 2
  • 11
  • 23
0

Years later and this is still a common problem, but its not always facebook's cache: It is very often human error (allow me to elaborate)

OG:TYPE effects your image scrape:

  1. https://ogp.me/#type_article not the same as https://ogp.me/#type_website

Be aware that og:type=website will cause any /sub-pages/ of that url to become "canonical". This means you will have trouble getting your images to update using the scraper no matter what you do.

Consider this "assumption and common mistake"

-<meta property="og:type" content="website" /> => https://www.example.org (parent)
-<meta property="og:type" content="website" /> => https://www.example.org/sub-page/
-<meta property="og:type" content="website" /> => https://www.example.org/sub-page/child-2/
- Ergo: /sub-page/ and /child-2/ will inherit the og:image of the parent

Those are not "all websites", 1 is a website, the others are articles.

If you do that Facebook will think all of those are canonical and it will put the FIRST og:image into all of them. (try it, you'll see) - if you set the og:url to be your root or parent domain you've told facebook they are all canonical. (there is good reason for that, but its off topic)

Consider this solution (which is what most people "really want")

-<meta property="og:type" content="article" /> => https://www.example.org/sub-page/
-<meta property="og:type" content="article" /> => https://www.example.org/sub-page/child-2/

If you do that now Facebook will give you far far less problems with scraping your NEW images.

In closing, YES the cache busters, random vars, changing urls and suggestions here can work, but they will seem like "intermittent voodoo" if the og:type is not specified correctly.

PS: remember that a CDN or serverside cache will serve to Facebook's scraper even if you "think" you can see the most recent version. (I wont spend any time on this other than to point out it will waste colossal amounts of your time if not double checked.)

Christian Žagarskas
  • 1,068
  • 10
  • 20
0

I had a different, but similar problem with Facebook recently, and found that the scraper/debug page mentioned, simply does not appear to read any page in its entirety. My meta properties for Open Graph were further down in the head section, and the scraper would constantly inform me that the image specification was not correct, and would use a cached version regardless. I moved the Open Graph tags further up in the code, near the very top of the page, and then everything worked perfectly, every time.

PaulScott
  • 117
  • 8
0

I had the same problem with fb and twitter caching old meta data, this threw me for a curve as I continued to edit the code but no change. I finally discovered they had caching my first request. Adding a query string to the url worked for twitter but not fb(for me).

jasenmichael
  • 388
  • 5
  • 17