如何清除 Facebook 共享器缓存?

发布于 2024-10-21 04:37:04 字数 262 浏览 13 评论 0原文

我们使用链接:

http://www.facebook.com/sharer.php?u=[shared URL]

...来共享特定页面。但是,Facebook Sharer 使用图像和标题的缓存版本。有没有办法快速清除 Facebook 缓存,或者我们需要等待多长时间才能更新数据?

我将 放在标签之间。

We used the link:

http://www.facebook.com/sharer.php?u=[shared URL]

...to share a particular page. However, Facebook Sharer uses the cached version of the images and the title. Is there a way to quickly clear the Facebook cache or how long do we have to wait until the data gets updated?

I placed <link rel='image_src' href='[preview image]' /> in between the tags.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

吾性傲以野 2024-10-28 04:37:04

我找到了解决问题的方法。您可以访问此网站:

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

。 ..然后输入您要共享的页面的URL,然后单击“调试”。它将自动提取元标记上的所有信息并清除缓存。

I found a solution to my problem. You could go to this site:

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

...then put in the URL of the page you want to share, and click "debug". It will automatically extract all the info on your meta tags and also clear the cache.

挽袖吟 2024-10-28 04:37:04

使用api 有没有强制的API Facebook 又要抓取页面了吗?

$furl = 'https://graph.facebook.com';

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $furl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POST, true );
$params = array(
    'id' => '<update_url>',
    'scrape' => true );
$data = http_build_query( $params );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );

curl_exec( $ch );
$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );

Use api Is there an API to force Facebook to scrape a page again?

$furl = 'https://graph.facebook.com';

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $furl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POST, true );
$params = array(
    'id' => '<update_url>',
    'scrape' => true );
$data = http_build_query( $params );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );

curl_exec( $ch );
$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
池木 2024-10-28 04:37:04

Facebook 将每个 url 视为唯一的,并根据该 url 缓存页面,因此如果您想共享最新的 url,最简单的解决方案是添加包含共享 url 的查询字符串。简单来说,只需在 url 末尾添加 ?v=1 即可。可以使用任何数字代替 1。

提示:Umair Jabbar< /a>

Facebook treats each url as unique and caches the page based on that url, so if you want to share the latest url the simplest solution is to add a query string with the url being shared. In simple words just add ?v=1 at the end of the url. Any number can be used in place of 1.

Hat tip: Umair Jabbar

向地狱狂奔 2024-10-28 04:37:04

我认为这两个链接对您的问题相关内容进行了广泛的讨论。 调用清除现金

fbml.refreshRefUrl

fb:ref 通过这样的

<tt>fbml.refreshRefUrl("http://www.mysite.com/someurl.php")

您可以从这里研究相关的内容 fb:ref 。我希望它对你有用

I thing these two links have a wide discussion on your problem related stuff. fb:ref clear cashes by calling

fbml.refreshRefUrl

like this

<tt>fbml.refreshRefUrl("http://www.mysite.com/someurl.php")

You can study the related stuff from here fb:ref. I hope it will work for you

心如狂蝶 2024-10-28 04:37:04

执行此操作的页面位于 https://developers.facebook.com/tools/debug/ 与其他一些答案相比略有变化。

将您的 URL 粘贴到其中并点击“调试”。然后点击 URL 文本字段下的“获取新的抓取信息”按钮,一切就都准备好了。它会从您的页面中提取新的元标记,但它们仍然会缓存,因此请记住,每当您更改它们时都需要执行此操作。如果您正在使用元标记来让 FB 共享 URL 按照您希望的方式在 facebook 内部进行格式化,这一点非常重要。

The page to do this is at https://developers.facebook.com/tools/debug/ and has changed slightly since some of the other answers.

Paste your URL in there and hit "Debug". Then hit the "Fetch new scrape information" button under the URL text field and you should be all set. It'll pull the fresh meta tags from your page, but they'll still cache so keep in mind you'll need to do this whenever you change them. This is really critical if you are playing with the meta tags to get FB Shared URLs to format the way you want them to inside of facebook.

梅倚清风 2024-10-28 04:37:04

这个答案是为开发人员准备的。

清除缓存意味着该网页的新共享将显示 OG 标签中提供的新内容。但前提是您正在处理的 URL 的互动次数少于 50 次(点赞 + 分享)。它也不会影响已发布在 Facebook 上的此网页的旧链接。只有当再次在 Facebook 上共享 URL 时,Facebook 显示链接的方式才会更新。

catandmouse 的答案是正确的,但您也可以通过向 graph.facebook.com 发送发布请求来清除 OG (OpenGraph) 缓存(在撰写本答案时适用于 http 和 https)。您不需要访问令牌。

到 graph.facebook.com 的 post 请求可能如下所示:

POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: graph.facebook.com
Content-Length: 63
Accept-Encoding: gzip
User-Agent: Mojolicious (Perl)

id=<url_encoded_url>&scrape=true

在 Perl 中,您可以使用以下代码,其中库 Mojo::UserAgent 用于发送和接收 HTTP 请求:

sub _clear_og_cache_on_facebook {
    my $fburl     = "http://graph.facebook.com";
    my $ua        = Mojo::UserAgent->new;
    my $clearurl  = <the url you want Facebook to forget>;
    my $post_body = {id => $clearurl, scrape => 'true'};
    my $res       = $ua->post($fburl => form => $post_body)->res;
    my $code      = $res->code;
    unless ($code eq '200') {
        Log->warn("Clearing cached OG data for $clearurl failed with code $code.");
        }
    }
}

通过终端发送此 post 请求可以通过以下命令:

curl -F id="<URL>" -F scrape=true graph.facebook.com

This answer is intended for developers.

Clearing the cache means that new shares of this webpage will show the new content which is provided in the OG tags. But only if the URL that you are working on has less than 50 interactions (likes + shares). It will also not affect old links to this webpage which have already been posted on Facebook. Only when sharing the URL on Facebook again will the way that Facebook shows the link be updated.

catandmouse's answer is correct but you can also make Facebook clear the OG (OpenGraph) cache by sending a post request to graph.facebook.com (works for both http and https as of the writing of this answer). You do not need an access token.

A post request to graph.facebook.com may look as follows:

POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: graph.facebook.com
Content-Length: 63
Accept-Encoding: gzip
User-Agent: Mojolicious (Perl)

id=<url_encoded_url>&scrape=true

In Perl, you can use the following code where the library Mojo::UserAgent is used to send and receive HTTP requests:

sub _clear_og_cache_on_facebook {
    my $fburl     = "http://graph.facebook.com";
    my $ua        = Mojo::UserAgent->new;
    my $clearurl  = <the url you want Facebook to forget>;
    my $post_body = {id => $clearurl, scrape => 'true'};
    my $res       = $ua->post($fburl => form => $post_body)->res;
    my $code      = $res->code;
    unless ($code eq '200') {
        Log->warn("Clearing cached OG data for $clearurl failed with code $code.");
        }
    }
}

Sending this post request through the terminal can be done with the following command:

curl -F id="<URL>" -F scrape=true graph.facebook.com
是你 2024-10-28 04:37:04

将 ?v=random_string 附加到 url。
如果您将此想法用于 Facebook 共享,请确保响应中的 og:url 参数
与您共享的网址匹配。这也适用于 google plus。

对于 Facebook,您还可以通过向 https://graph.facebook.com 发出发布请求来强制重新抓取

{id: url,
scrape: true}

Append a ?v=random_string to the url.
If you are using this idea with Facebook share, make sure that the og:url param in the response
matches the url you are sharing. This will work with google plus too.

For Facebook, you can also force recrawl by making a post request to https://graph.facebook.com

{id: url,
scrape: true}
只为一人 2024-10-28 04:37:04

我刚刚在相关帖子上发布了一个简单的解决方案,需要 5 秒钟 - Facebook 调试器:清除整个网站缓存

简短的回答...将永久链接设置中的 worpdress 网站上的永久链接更改为自定义链接。我刚刚添加了一个下划线。
/_%帖子名%/
然后 Facebook 将它们全部作为新的网址、新的帖子进行抓取。

I just posted a simple solution that takes 5 seconds here on a related post here - Facebook debugger: Clear whole site cache

short answer... change your permalinks on a worpdress site in the permalinks settings to a custom one. I just added an underscore.
/_%postname%/
then facebook scrapes them all as new urls, new posts.

絕版丫頭 2024-10-28 04:37:04

如果您使用带有缓存插件的 WordPress,请确保清除所有缓存。另请确保您使用的图像具有建议的 Facebook 尺寸:1200(宽)x 630(高)或 600 x 315。

if you are using wordpress with a cache plugin, make sure you clear all your caches. Also make sure the image you are using has the recommended facebook size: 1200(w) x 630(h) or 600 x 315.

怪异←思 2024-10-28 04:37:04

如果您使用托管 WordPress 或缓存插件,则必须先清除缓存,然后 facebook 调试器工具才能获取新信息!

几个星期以来,我一直在绞尽脑汁地想弄清楚为什么我所做的更改在 24 小时内都不会显示在 facebook 调试器中!!!!解决方法是我必须进入我的 WordPress 仪表板,单击顶部的 godaddy 图标,然后单击“刷新缓存”。我认为许多托管 WordPress 托管商都有一个缓存来弄清楚如何清除它,你会很高兴。

If you used managed wordpress or caching plugins, you have to CLEAR YOUR CACHE before the facebook debugger tool can fetch new info!

I've been pulling my hair out for weeks figuring out why changes I made wouldn't show up in facebook debugger for 24 hours!!!! The fix is I have to go into my wordpress dashboard, click the godaddy icon on the top, and click "flush cache." I think many managed wordpress hosters have a cache to figure out how to clear it and you'll be golden.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文