Facebook Open Graph 未清除缓存
我在使用 Open Graph 时遇到元标记问题。 Facebook 似乎正在缓存我的元标记的旧值。属性 og:title
和 og:url
的旧值仍然使用,即使我已经更改了它们。
我在 我网站的页面 上运行 Lint,结果出现:
请注意,og:title
和 og:url
有两个值>,最后一个占了上风。但是,最后两个条目是我用于此网站的旧条目。我现在正在使用这些元标记(您可以查看 HTML 源代码来验证):
<meta property="og:title" content="Smart og rummelig pusletaske fra Petit Amour med god plads til alt – værdi 1.099 kr – 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
?有人遇到同样的问题吗?
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:
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 – værdi 1.099 kr – 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
投票最多的问题已经过时了:
这是截至2014 年 11 月应该使用的唯一 2 个选项:
对于非开发人员
(针对开发人员)
关于更新图像的附加信息
有关先前发布的帖子中的图像或视频更新的注意事项:
The most voted question is quite outdated:
These are the only 2 options that should be used as of November 2014:
For non developers
For Developers
Additional Info About Updating Images
Note regarding image or video updates on previously posted posts:
如果您有很多页面并且不想手动刷新它们 - 您可以自动刷新。
假设您有带有照片的用户个人资料页面:
只需将其添加到您的页面:
这将刷新 Facebook 缓存。如果您使用 jQuery 解决方案,请查看 console.log 中的“response” - 您会发现其中的“updated_time”字段和其他有用信息。
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:
Just add this to your page:
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.
即使传递 fbrefresh 变量,OG 缩略图似乎也不会刷新。
要更新此内容而不等待自动清除,您需要更改缩略图关联元标记值的文件名并刷新。
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.
基本上,答案就是耐心;)
今天早上我检查了 Linter,og:title 和 og:url 显示正确,没有多余的值。我猜 Facebook 会在某个特定的时间间隔自动清除缓存。我只需要等待。
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.
我在使用 og:image 时遇到了同样的问题,多次尝试重命名文件或清除 FB 缓存,但无论是通过 facebook 调试器还是通过实际帐户进行测试都不起作用。
新的 Facebook 指南规定图像尺寸应为 1200 x 630 或具有该纵横比,这似乎是错误的,唯一对我有用的是使用方形尺寸的图像。
编辑* 几个小时后,我又重新使用 1200 x 630,它神奇地工作了,太神奇了。
我还将这些文件重命名为 f*^*kfacebook.jpg,不确定是否有帮助,但感觉很好。
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.
是的,Facebook 每 24 小时自动清除一次缓存:实际上 facebook 每 24 小时就会抓取页面并更新缓存 https://developers.facebook.com/docs/reference/plugins/like/#scraperinfo。
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.
哦哦,终于有帮助了(我使用 IP.Board)。我要做的是:
感谢作者提供此帖子!
编辑:您还需要记住图像要求。目前(2013 年 1 月)是:
- 两个方向至少 200 px
- 最大比例3:1
Ooook, finally it helped (I use IP.Board). What I had to do was:
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
抱歉,各位,正确的答案是:
没有万无一失的方法可以立即更新开放图 og:image url。它会被缓存,直到 Facebook 更新(据报道每 24 小时更新一次)
以下是其他人报告的有效方法,但我对其中任何一个都取得了零成功。
检查您的代码始终是确认它不是浏览器缓存或某些缓存服务的问题的方法。如果您的代码中的元信息是最新的,并且您已经尝试了上述所有方法(除非另一个建议得以实现),那么正确的答案是您只能等待。
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.
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.
我们刚刚遇到了这个问题,事实证明,我们没有检查正确的 url,因为真正的 url 有一个查询字符串(呃,就机器人而言,是不同的页面)。
http://example.com/
!==
http://example.com/?utm_campaign=foo
linter将重新缓存您的页面,您不必等待。
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.
需要补充的一件事是,网址区分大小写。注意:
在 linter 眼中是不同的
请务必使用在应用程序的开发人员设置中输入的确切网站网址。否则,linter 将返回属性,但不会刷新缓存。
One thing to add, the url is case sensitive. Note that:
is different in the linter's eyes then
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.
我发现如果你的图像是 72dpi 它会给你图像尺寸错误。请改用 96dpi。希望这有帮助。
I've found out that if your image is 72dpi it will give you the image size error. Use 96dpi instead. Hope this helps.
转到http://developers.facebook.com/tools/debug
粘贴页面的 url,然后单击“调试”。如果您的网站使用网址别名,请确保您使用与 Facebook 相同的网址
用于您正在共享的页面(例如:在 Drupal 中使用
如果页面是通过该路径共享的,则使用 node/* 路径而不是别名
网址)。
Go to http://developers.facebook.com/tools/debug
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).
Facebook 开发者文档称 title 属性有例外:
https:// Developers.facebook.com/docs/sharing/opengraph/using-objects#update
Facebook Developer Documents says title property has exception:
https://developers.facebook.com/docs/sharing/opengraph/using-objects#update
有过类似的经历。网站链接在 Facebook 生成的预览中显示 404。事实证明 og:url 元数据是错误的。几天前我们已经修复了这个问题,但在预览中仍然看到 404 错误。我们使用了 https://developers.facebook.com/tools/debug/ 上的工具,并且强制刷新(不必顺便附加任何参数)
在我们的例子中,Facebook 在 24 小时后没有刷新缓存,但该工具帮助强制刷新。
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.
它是一个缓存,它会刷新,这就是缓存偶尔要做的事情。所以等待最终会奏效,但有时你需要更快。更改文件名有效。
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.
我也遇到了这个问题。抓取工具显示了正确的信息,但共享 URL 仍填充有旧数据。
我解决这个问题的方法是使用 feed 方法,而不是共享,然后手动填充数据(不会通过共享方法公开),
如下所示:
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:
真的很容易解决。已测试并工作。您只需要在更新元标记时生成一个新的网址即可。就像在您的网址中添加“&cacheBuster=1”一样简单。如果您更改元标记,只需增加“&cacheBuster=2”
原始 URL
元标记更新时的 URL:
元标记更新时的 URL再次更新:
Facebook 会将每个 URL 视为新的 URL,并获取新的元数据。
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
URL when og meta tags are updated:
URL when og meta tags are updated again:
Facebook will treat each like a new url and get fresh meta data.
几年后,这仍然是一个常见问题,但它并不总是 Facebook 的缓存:这通常是人为错误(请允许我详细说明)
OG:TYPE 影响您的图像抓取:
请注意 og:type=website 将导致该 url 的任何 /sub-pages/ 变为“典范”。这意味着无论您做什么,都很难使用抓取工具更新图像。
考虑这个“假设和常见错误”
-
=> https://www.example.org(父级)
-
=>; https://www.example.org/sub-page/
-
=>; https://www.example.org/sub-page/child-2/< /a>
- 因此:
/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/< /a>
如果你现在就这样做,Facebook 会给你带来更少的抓取新图片的问题。
最后,是的,这里的缓存破坏程序、随机变量、更改网址和建议都可以工作,但如果未指定 og:type ,它们看起来就像“间歇性巫毒”正确。
PS:请记住,即使您“认为”可以看到最新版本,CDN 或服务器端缓存也将为 Facebook 的抓取工具提供服务。 (我不会花任何时间在这上面,只是指出如果不仔细检查的话会浪费你大量的时间。)
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:
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 theog:image
of the parentThose 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.)
我最近在 Facebook 上遇到了一个不同但类似的问题,并发现提到的抓取/调试页面似乎没有完整地读取任何页面。我的 Open Graph 元属性位于头部的下方,抓取工具会不断地通知我图像规范不正确,并且无论如何都会使用缓存版本。我将开放图标签在代码中进一步移动到页面顶部附近,然后每次都一切正常。
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.
我在 Facebook 和 Twitter 缓存旧元数据时遇到了同样的问题,这让我在继续编辑代码时遇到了麻烦,但没有任何改变。我终于发现他们缓存了我的第一个请求。在 url 中添加查询字符串适用于 twitter,但不适用于 fb(对我来说)。
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).
fbrefresh=CAN_BE_ANYTHING
示例:
http://www.example.com?fbrefresh=CAN_BE_ANYTHING
http://www.example.com?postid=1234&fbrefresh=CAN_BE_ANYTHING
http://developers.facebook.com/tools/debug/og/object?q=http://www.example.com/?p=3568&fbrefresh=89127348912
我也有同样的情况昨晚出现这个问题,我从某个网站得到了这个解决方案。
Facebook 会保存您的缓存缩略图。即使您从服务器中删除缩略图/图像,它也不会刷新。但 Facebook 允许您使用
fbrefresh
进行刷新。fbrefresh=CAN_BE_ANYTHING
Examples:
http://www.example.com?fbrefresh=CAN_BE_ANYTHING
http://www.example.com?postid=1234&fbrefresh=CAN_BE_ANYTHING
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
.