即使查询参数更改,Facebook 共享预览也会缓存 og 标签
Facebook share preview caches og tags even when the query parameters are changed
我正在使用 php 来获得基于 url 参数的动态 og:image,但是,即使查询字符串不同,facebook 仍然缓存我的默认图像设置
<?php
$selection = $_GET['selection'];
$mixName = $_GET['mixName'];
$title = "App title";
$description = "Default description";
$image = "default image url";
if ($selection) {
$dynamicContent = file_get_contents('calling server to get custom image based on query parameters $selection);
$data = json_decode($dynamicContent, TRUE);
if ($data['image']) {
$image = $data['image'];
}
if ($mixName) {
$title = $mixName;
}
}
?>
<meta name="description" content="description">
<meta property="og:title" content="<?php echo $title ?>">
<meta property="og:url" content="website url">
<meta property="og:description" content="testabc">
<meta property="og:type" content="website" />
<meta property="og:image" content="<?php echo $image ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo $title ?>">
<meta name="twitter:image" content="<?php echo $image ?>">
<meta name="twitter:description" content="<?php echo $description ?>">
我还进行了测试以检查 http 与 https 网站,我注意到我的 PHP 脚本在 HTTP(不安全)环境中工作正常,我总是在共享预览中获得正确的图像。
我还使用 facebook 共享调试器从我的网站手动删除缓存,但仍未呈现自定义图像。
我知道自定义图像很好,因为当我实际点击 link 并进入页面 -> 检查时 og:image 标签实际上是 link 我的动态图片 URL.
我读过许多 post 更改查询参数不应使用缓存,但它对我不起作用。
php获取动态图像的请求方法平均需要2-3秒来解决。如果尚未解决,Facebook 是否会使用旧缓存作为最大限制共享?
感谢任何信息
您还需要在 og:url
中指定查询字符串参数。
Facebook 将其视为您分享的内容的“真实”URL,并将从那里请求其余的 OG 元数据。
请注意,指定不同的 URL 也会在这些 URL 之间拆分您的点赞和分享计数,即使您认为它们基本上是同一块内容。对于 Facebook,不同的 OG URLs,意味着不同的 Open Graph Objects。
我正在使用 php 来获得基于 url 参数的动态 og:image,但是,即使查询字符串不同,facebook 仍然缓存我的默认图像设置
<?php
$selection = $_GET['selection'];
$mixName = $_GET['mixName'];
$title = "App title";
$description = "Default description";
$image = "default image url";
if ($selection) {
$dynamicContent = file_get_contents('calling server to get custom image based on query parameters $selection);
$data = json_decode($dynamicContent, TRUE);
if ($data['image']) {
$image = $data['image'];
}
if ($mixName) {
$title = $mixName;
}
}
?>
<meta name="description" content="description">
<meta property="og:title" content="<?php echo $title ?>">
<meta property="og:url" content="website url">
<meta property="og:description" content="testabc">
<meta property="og:type" content="website" />
<meta property="og:image" content="<?php echo $image ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo $title ?>">
<meta name="twitter:image" content="<?php echo $image ?>">
<meta name="twitter:description" content="<?php echo $description ?>">
我还进行了测试以检查 http 与 https 网站,我注意到我的 PHP 脚本在 HTTP(不安全)环境中工作正常,我总是在共享预览中获得正确的图像。
我还使用 facebook 共享调试器从我的网站手动删除缓存,但仍未呈现自定义图像。
我知道自定义图像很好,因为当我实际点击 link 并进入页面 -> 检查时 og:image 标签实际上是 link 我的动态图片 URL.
我读过许多 post 更改查询参数不应使用缓存,但它对我不起作用。
php获取动态图像的请求方法平均需要2-3秒来解决。如果尚未解决,Facebook 是否会使用旧缓存作为最大限制共享?
感谢任何信息
您还需要在 og:url
中指定查询字符串参数。
Facebook 将其视为您分享的内容的“真实”URL,并将从那里请求其余的 OG 元数据。
请注意,指定不同的 URL 也会在这些 URL 之间拆分您的点赞和分享计数,即使您认为它们基本上是同一块内容。对于 Facebook,不同的 OG URLs,意味着不同的 Open Graph Objects。