If you’ve used Facebook’s share functionality on an external website, you have probably by now figured out that the first time Facebook accesses the shared link, it generates a cache of the preview image and the copy. Here are a few tips to break the cache.

First, I should mention that the Facebook cache is there for good reason, to better handle load from their over 500 million users. The challenge comes in when you forgot to implement the proper meta information to make your share preview look as nice as it could, and you try to add it in after it’s been cached. You’ll change or add meta information, but Facebook still shows the older, crummy version.

The easiest way to break the Facebook share cache is to use a slightly different url, such as www.example.com versus www.example.com/index.htm.

Alternately, you can tack a query string onto the end of the url to make it a slightly different url in Facebook’s eyes, such as www.example.com versus www.example.com/?v1, www.example.com/?v2, etc.

This is fine for most manual share buttons, since you’re able to specify the url, but the problem comes in when you’ve got a website that people have already been sharing, with or without a share button provided.

The first time any user shared that specific url on Facebook, even if you didn’t have a share button implemented yet, Facebook cached the data. Facebook cached the preview image(s), the title and the description copy.

This caching also means that the first time you test what your site looks like in a Facebook share, it gets cached – so if the result isn’t what you wanted, you’ve now been hoist by your own petard.

Maybe you were ready, maybe you weren’t. Maybe you updated some copy, or came up with a better preview image. Either way, it can be frustrating to know that you’ve added or updated meta information and it’s still showing the older version.

It’s also a problem when you’re using the share widget that tracks the number of likes and shares from Facebook users. Changing that url, even slightly, will wipe out those stats, since Facebook sees it as a brand new url, so those 91k shares your page received will be zeroed out if you start mucking with the share url.

I’ve heard unofficial reports that Facebook caches this information for anywhere from one day to a week. This can be inconvenient at best, and cataclysmic at worst (in the case where a typo or critical copy change came down from corporate.)

Fortunately, there is a well-hidden tool that can help speed that up.

Facebook provides a URL Linter that will let you preview what your page will look like in the share preview without condemning you to being stuck with it for a week.

As you can see, the URL linter offers a preview, and some helpful debugging information about your url.

One side-effect of the URL linter is that it clears the cached data for the url you’re previewing.

Oddly, it does seem to be case-sensitive, so if your share url is www.Example.Com, make sure you enter www.example.com and www.Example.Com into the linter.

Also be aware that, as we mentioned, www.example.com and www.example.com/index.htm are two different urls according to Facebook. And depending on your server configuration, www.example.com and example.com might also be different urls, so be sure to cover all your bases.

A Better Use

Because it’s Facebook, I would recommend not abusing this tool, and instead using it the way it was intended. Breaking the Facebook share cache should be a last resort, and you’ll be better served by using it to plan ahead instead of fixing things, since Facebook could remove or change this functionality at any time.

Instead, use the linter on a url before you launch to preview what the share will look like. Use it to perfect the preview image and copy, and then go live. (Note that it will not work if your website is password-protected via htaccess or IP restrictions, since the outside world can’t access it, which means Facebook can’t access it.)

Use the debugging beforehand to make sure your page is optimized for Facebook sharing, even if you don’t plan on implementing a share button on the page itself. Someone, somewhere is going to share that bad boy, so you may as well be ready.

To learn more about the meta tags to use to specify which images and copy you want Facebook to use in share dialog, check out the share docs. (Bear in mind that some reports state that Facebook stops crawling a page after a certain number of characters, so the higher up on the page this meta information appears, the better.)

ssd-virtual-servers-banner-468x60

Advertisement

468x60_makemoney
Previous post

AppBistro: Third-Party Marketplace for Facebook Applications

beach-xss
Next post

Firefox Addons for Penetration/XSS Testing

snipe

snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist. I'm the CTO at Mass Mosaic and the CEO of Grokability, Inc. in San Diego, CA. Tweet at me @snipeyhead or read more...

  • maria k

    very nice tut´s and help here i am really happy i found this site to overcome all FB issues

    thanks for sharing

  • thank you so much

  • It seems like the URL linter isn’t breaking the cache for me today (21 Oct 2010). Is it possible Facebook modified the linter to remove that ‘feature’?

    • Could be, but it’s more likely that something is just wonky today. I’ve had it take longer some days.

  • You just saved Mark from receiving a Molotov, thanks.

  • Great article, thanks for helping me out.

  • Liz

    genius, thank you!

  • Thanks, this is something I have been looking for for a while!
    http://www.celticwebdesign.net

  • Gsanjeevkumar

    cool tip!

  • andrejevics

    Thank you. It was _really_ helpful!

  • Audrey

    you are a life saver. I’ve been struggling over my stupid image not showing up forever! Question, any idea what the default size of the preview image is? I have on at 75px by 75px and it enlarges the image causing it to blur

  • Thanks a lot for sharing this information. Facebook Lint saved the day when a client wanted to display the sites metadata after the initial launch and shares, and they didn’t want to wait on a cache flush ofcourse!

  • Mark

    great stuff. happy client now. thanks.

  • Afzal94123

    thanks really very useful

  • Beyond helpful. Thank you!

  • Anonymous

    Thanks so much for this! You saved me a lot of time in trying to pin down the caching issue I was having. Unfortunately, since I’m doing ad work, there’s not real way to “test it completely before deployment”, since clients have no concept of “final delivery” for copy. But the linter will help me for when they make changes to do a quick cache purge! Thanks!

    • Ahh yes, I know that drill all too well 🙂 Glad it helped!

  • Moe

    Great article. This was exactly what I was looking for! =)

  • ZaHACKieL

    Hi snipe! (luv your web) I had a like button in my website for each post but now I reprogrammed the web and changed the urls from something like myweb.com/file.php?id=xx to myweb.com/title-of-the-post . I also changed the url fb meta tag and as you said, I lost the count. But what I did was to keep the old url fb metatag and use the Linter for each post and then changed the fb url tag again to the new format and the old count worked with the new url. At least for one day =[ . I guess I don’t want to have a URL and a different fb url tag…do you have any ideas to keep the old count?

    • ZaHACKieL

      Oh just an update. Since I know which posts are “old”, (i.e. people have already liked them using the old url format) and which are new (i.e. have the new url format) what I did is, if the post is “old” then the fb url tag uses the old url format and viceversa so for now is working fine. The downside I thought about this is that I don’t want to have duplicated urls (the old one and the rewritten new one) but reality is that the old ones are already in facebook because of the people that liked them. Anyway, long text sorry -_-b . Let me know what you think about it!

  • JustinL

    Thanks for the solution.

    As a web dev who finds himself often caching data, I often worry about how to force-clear data a result.

    I wish this article wasn’t about breaking it – or suggesting that “this isn’t intended”. The facebook developers *have* to assume that the cache is outdated if a web developer is suggesting that the content has changed (which is what this page is!). It only makes sense that it clears it.

    Further, you *should* use this tool to reset the cache. I don’t know what “abuse” is in this case. This is provided for debug purposes – clearly it’s meant to be hit as many times as you need to to get your code right so you can make facebook better (from their POV that’s what’s happening).

    Caching is responsible – but so is being able to clear it.

    • “This is provided for debug purposes – clearly it’s meant to be hit as many times as you need to to get your code right so you can make facebook better (from their POV that’s what’s happening). ”

      I don’t think Facebook intended this as a tool to use when you’re making 500 small copy tweaks to your share text. That’s my point. Use it, but use it responsibly.

  • Dave

    Thanks. I messed this all day until I found your article. You rock.

  • Thanks a lot 🙂

  • Ariel

    Great Post! Thanks. you saved my life today 🙂

  • Shreelasen

    I did not understand. I am trying to copy the url of my blog & share. But the link I get is of an older post.
    I checked in the linter. It displays the information that is being linked – that is old.
    How to “use” the linter?

    • I assume you mean the preview content you get is of an older post, not the link?

      By checking it in the linter, you’ve used it. You may need to wait a few hours to see the updated share dialog tho.

  • Anonymous

    Very helpful, thanks a lot!

  • Sehkraft

    Thank you so much, just what i was looking for!

  • I am so frustrated about this… every single one of my website links no longer posts properly and I have to use the linter 100 times a day!

  • Thanks for this, I was beginning to worry my sites info would stay cached forever!

  • Wow thank you so much for this helpful information. I searched for so long for mistakes on my side to find this…

  • Antonio

    Thank you very much from Spain, you saved my life and website 🙂

  • Peeks

    To manually refresh FB cache of a link use FB’s tool below:

    http://developers.facebook.com/docs/reference/rest/fbml.refreshRefUrl/

    =)

    • You’re correct that it should work, but that function is part of the legacy REST API which is being deprecated and will at some point no longer work. It would probably be an unusual case where you would need to programmatically clear the FB cache of a url, so the linter will likely be a more practical solution.

  • Cradic3143

    Hei where the f*ck were you, many time looking for this tutorial, THANKS A LOT 

    • Uhm, you’re welcome?

  • Tt

    Thanks

  • APeterson

    Thanks for the great article. Unfortunately, the Facebook debugger does not clear the cache for me — it never has. My workflow is to test how the ‘like’ post looks before I finalize the code. The first post looks as expected — the image, title and description match the tags in my code. However, when I make corrections or updates, the changes appear correctly in the debugger, but they never appear in the post on my wall (where I’m testing my work). I’ve tried it many times over several days and my test ‘likes’ continue to display the original (first post) information. 
    Since these are new ‘like’ buttons, I can’t imagine I’m running into the 50-‘like’ limit which locks down some of the og meta tags. Any other tips?

    • Hi APeterson – I’m sorry to hear that – can you share the url you’re having trouble with?

  • Thank you for this, a MASSIVE help!

  • Thank you so much

  • Anonymous

    I recently needed to purge the share cache for a 100+ pages after a client change request. I wrote a quick script to purge from a list stored in a text file.

    https://github.com/ifnull/FB_CacheBuster

  • Thank you for this!

  • Guest

    thanks (like everyone else)

  • yitwail

    like everyone else, thanks!