Facebook 之类 - 显示缓存版本 og:image,如何刷新或重新索引它?

发布于 2024-12-06 19:05:47 字数 971 浏览 0 评论 0原文

Facebook like 和缓存的 og:image 存在问题。

长话短说: Facebook 缓存了我们点赞图片的旧版本。元内容 URL 无法更改。我可以做些什么来刷新它吗?

长话短说: 我正在开发的网站有一个 og:image 的元标记,Facebook 在喜欢某个页面时会使用该元标记。此元标记在网站的所有页面上使用相同的图像 URL。该图像只是该网站的品牌形象。

问题是该网站最近更新了其品牌,而我们无法更新类似 Facebook 的图像。当用户点击“赞”链接时,Facebook 上发布的帖子仍然显示旧的品牌形象。

元标记类似于:

<meta property="og:image" content="http://[domain].com/images/bookmark/apple-touch-icon.png"/>

每当有赞到达 Facebook 时,图像的 URL 就会更改为缓存的 Facebook URL,类似于:

http://external.ak.fbcdn.net/safe_image.php?d=AQDajxm-qgVNdfEL&w=90&h=90&url=http%3A%2F%2F[domain].com%2Fimages%2Fbookmark%2Fapple-touch-icon.png

此 URL 显示网站品牌的旧版本。已经一个多星期了,还没更新。

有什么方法可以强制 Facebook 重新索引图像/清除其缓存吗?或者,Facebook 会定期自动执行此操作吗?我找不到这方面的任何相关信息。

我知道更改元标记中的 URL 可以解决该问题,但元标记是由跨多个站点使用的代码生成的,无法更改。我还按照其他人的建议尝试了 delinter 工具。运气不好。

Having an issue with Facebook like and a cached og:image.

Long story short:
Facebook has cached an older version of our like image. The meta content URL can't be changed. Is there anything I can do to refresh it?

Long story:
The site I'm working on has a meta tag for an og:image that Facebook uses when a page is liked. This meta tag uses the same image URL on all pages across the site. The image is simply a branding image for the site.

The issue is the site recently updated their branding, and we can't get the Facebook like image to update. When a user clicks the like link, the resulting post to Facebook still shows the old branding image.

The meta tag is similar to:

<meta property="og:image" content="http://[domain].com/images/bookmark/apple-touch-icon.png"/>

Whenever a like makes its way to Facebook, the URL to the image is changed to the cached Facebook URL, similar to this:

http://external.ak.fbcdn.net/safe_image.php?d=AQDajxm-qgVNdfEL&w=90&h=90&url=http%3A%2F%2F[domain].com%2Fimages%2Fbookmark%2Fapple-touch-icon.png

This URL displays the older version of the site's branding. It has been over a week, and it has not updated yet.

Is there any way to force Facebook to reindex the image/clear it's cache? Or, does Facebook periodically do this automatically? I couldn't find any relevant information on this.

I know that changing the URL in the meta tag could fix the issue, but the meta tag is generated by code used across multiple sites and it can not be changed. I also tried the delinter tool as was suggested to me by others. No luck.

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

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

发布评论

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

评论(6

堇色安年 2024-12-13 19:05:47

将您的 URL 插入他们的 linter 中,它应该重新加载其缓存

Insert your URL into their linter and it should reload its cache

乖不如嘢 2024-12-13 19:05:47

您可以使用 Facebook 的对象调试器,它允许您输入页面 URL,然后在下一页上您可以在“获取新抓取信息”的请求中重新提交它。这将清除 Facebook 给定 URL 的缓存 - 并不是说​​它可能需要一些时间才能在所有缓存节点上传播。

Facebook 的对象调试器可以在这里找到:
https://developers.facebook.com/tools/debug/

我们最近发现 Facebook使用针对相对 URL 的查询字符串来缓存 URL,并且查询字符串被忽略,这弄乱了我们纯粹基于查询字符串提供的一些动态图像。

事实证明,您可以指定最后修改的时间戳(以 Unix 时间戳格式),以帮助确保当 FB 抓取您的网站时,它始终获得正确的图像。

这可以通过包含以下 OG 元标记来完成:

<meta property="og:updated_time" content="123465789" />

对于动态站点,您需要生成内容值 - 使用 PHP,可以插入当前的 Unix 时间戳,如下所示:

<meta property="og:updated_time" content="<?=time()?>" />

You can use Facebook's object debugger which will allow you to enter the page URL and then on the next page you can re-submit it in a request to 'Fetch new scrape information'. This will clear Facebook's cache for the given URL - Not that it may take some time to propagate around all their cache nodes.

Facebook's Object Debugger can be found here:
https://developers.facebook.com/tools/debug/

We recently found that Facebook was caching URLs using a query string against the relative URL and that the query string was being ignored which messed up a few dynamic images we were serving purely based on the query string.

It turns out that you can specify a last modified timestamp (in Unix timestamp format) to help ensure when FB crawls your site, it always gets the correct image.

This can be done by including the following OG meta tag:

<meta property="og:updated_time" content="123465789" />

For dynamic sites you'll want to generate the content value - using PHP the current Unix timestamp can be inserted as follows:

<meta property="og:updated_time" content="<?=time()?>" />
可爱咩 2024-12-13 19:05:47

我想到了一个可能的解决方案...如果在 URL 末尾添加一个随机字符串会怎样?

就像 www.server.com/something.php?v=
或者
www.server.com/something.jpg?v=

我猜 facebook cahce 对象取决于 url...随机更改它...可以帮助。

I have think a possible solution... what if you add at the end of the URL a random string?

like www.server.com/something.php?v=<?php echo rand() ?>
or
www.server.com/something.jpg?v=<?php echo rand() ?>

i guess facebook cahce object depending on the url... change it randomly... could help.

夏末 2024-12-13 19:05:47

这篇文章发布 7 年后,这仍然是一个问题,但它不是 facebook 的缓存:这是人为错误(请允许我详细说明)

OG:TYPE 影响您的图像抓取:

  1. https://ogp.me/#type_article 不同https://ogp.me/#type_website

请注意,og:type=website 会导致该网址的任何/子页面/成为“规范”。这意味着无论您做什么,都很难使用抓取工具更新图像。

考虑这个“假设和常见错误”

- => https://www.example.org(父级)
- =>; https://www.example.org/sub-page/
- =>; https://www.example.org/sub-page/child-2/
- 因此:/sub-page//child-2/ 将继承父级的 og:image

这些不是“所有网站” 》,1为网站,其他为文章。

如果你这样做,Facebook 会认为所有这些都是规范的,并且会将第一个 og:image 放入所有这些中。 (尝试一下,你就会看到) - 如果你将 og:url 设置为你的根域或父域,你就告诉 Facebook 它们都是规范的。 (这是有充分理由的,但它偏离主题)

考虑这个解决方案(这是大多数人“真正想要的”)

- => https://www.example.org/sub-page/
- =>; https://www.example.org/sub-page/child-2/

如果你现在就这样做,Facebook 会给你带来更少的抓取新图片的问题。

最后,是的,这里的缓存破坏程序、随机变量、更改网址和建议都可以工作,但如果未指定 og:type ,它们看起来就像“间歇性巫术”正确。

PS:请记住,即使您“认为”可以看到最新版本,CDN 或服务器端缓存也将为 Facebook 的抓取工具提供服务。 (我不会花任何时间在这上面,只是指出如果不仔细检查的话会浪费你大量的时间。)

7 years later after this post was made and this is still a problem, but its not facebook's cache: It is 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.)

浅沫记忆 2024-12-13 19:05:47
  1. 更改 og:image 的 URL:

将图像示例

<meta property="og:image"         content="https://abc.lk/img/share-english.jpg" />

更新为

<meta property="og:image"         content="https://abc.lk/img/share-english-1.jpg" />
  1. 转到 https 时, //developers.facebook.com/tools/debug/sharing

  2. 添加 url - 单击“调试”

  3. 检查抓取时间并再次单击“抓取”< /p>

  1. Change the URL of the og:image when you update the Image

example

<meta property="og:image"         content="https://abc.lk/img/share-english.jpg" />

to

<meta property="og:image"         content="https://abc.lk/img/share-english-1.jpg" />
  1. go to https://developers.facebook.com/tools/debug/sharing

  2. Add url - click debug

  3. Check Time Scraped and Click Scrape again

何时共饮酒 2024-12-13 19:05:47
<meta property="og:image" content="https://example.com/image.jpg?v=<?= time() ?>" />

这是我的解决方案,使用 ?v=UNIX_TIMESTAMP
但你仍然必须再次获取页面。

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

<meta property="og:image" content="https://example.com/image.jpg?v=<?= time() ?>" />

This was my solution, using ?v=UNIX_TIMESTAMP
but still you have to fetch page again.

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

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