[英]AMP update-cache resulting in 404 or 410 error from origin
I've been trying to update the AMP cached pages on my website for a couple of days now to no avail.几天来,我一直在尝试更新我网站上的 AMP 缓存页面,但无济于事。
While the documentation for updating the cache exists, it was probably written by a Google engineer, and as a result, isn't the easiest read.虽然存在更新缓存的文档,但它可能是由 Google 工程师编写的,因此不是最容易阅读的。
https://developers.google.com/amp/cache/update-cache
https://developers.google.com/amp/cache/update-cache
I've followed the directions to the best of my ability.我已尽我所能按照指示进行操作。 I've created a private-key and public-key.
我已经创建了一个私钥和公钥。 Created a signature.bin and verified it using the procedure in Google's own documentation.
创建了一个 signature.bin 并使用 Google 自己的文档中的过程对其进行了验证。
~$ openssl dgst -sha256 -signature signature.bin -verify public-key.pem url.txt
~$ openssl dgst -sha256 -signature signature.bin -verify public-key.pem url.txt
Verified OK
验证正常
The public-key.pem has been renamed to apikey.pub and uploaded to the following directory: public-key.pem 已重命名为 apikey.pub 并上传到以下目录:
https://irecover.ca/.well-known/amphtml/apikey.pub
https://irecover.ca/.well-known/amphtml/apikey.pub
To validate that there has been no issue in the copying, I checked the signature using the following:为了验证复制没有问题,我使用以下命令检查了签名:
$ openssl dgst -sha256 -signature signature.bin -verify <(curl https://irecover.ca/.well-known/amphtml/apikey.pub ) url.txt
$ openssl dgst -sha256 -signature signature.bin -verify <(curl https://irecover.ca/.well-known/amphtml/apikey.pub ) url.txt
% Total % Received % Xferd Average Speed Time Time Time Current
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
下载上传总花费的剩余速度
100 450 100 450 0 0 2653 0 --:--:-- --:--:-- --:--:-- 2662
100 450 100 450 0 0 2653 0 --:--:-- --:--:-- --:--:-- 2662
Verified OK
验证正常
Now I convert the signature file to base64 and replace the / with _ and the + with -现在我将签名文件转换为 base64 并将 / 替换为 _,将 + 替换为 -
cat signature.bin |
猫签名.bin | base64 > signature.b64
base64 > 签名.b64
sed 's///_/g' signature.b64 > signature.b64a
sed 's///_/g' 签名.b64 > 签名.b64a
sed 's/+/-/g' signature.b64a > signature.b64b
sed 's/+/-/g' 签名.b64a > 签名.b64b
sed 's/=//g' signature.b64b > signature.b64c
sed 's/=//g' 签名.b64b > 签名.b64c
cat signature.b64c |
猫签名.b64c | tr -d '\\n' > signature.b64
tr -d '\\n' > 签名.b64
I have made a script that makes the update-cache url for me.我制作了一个脚本,为我制作更新缓存 url。 It also creates a timestamp right that moment and uses it for the amp_ts variable (So the amp_ts is never out by more than 1 second).
它还在那一刻创建一个时间戳并将其用于 amp_ts 变量(因此 amp_ts 永远不会超过 1 秒)。 I then append that to the end of the query which is about to be cURL'd by the script I have made, so it looks like so:
然后我将它附加到查询的末尾,该查询将被我制作的脚本卷曲,所以它看起来像这样:
https://irecover-ca.cdn.ampproject.org/update-cache/c/s/irecover.ca/article?amp_action=flush&_ts=1581446499&_url_signature=KDaKbX0AbVbllwkTpDMFPOsFCRNw2sbk6Vd552bbG3u5QrecEmQ1SoMzmMR7iSXinO7LfM2bRCgJ1aD4y2cCayzrQuICrGz6b_PH7gKpo6tqETz06WmVeiP89xh_pBOu-pyN5rRHf0Pbu8oRkD2lRqgnGrLXDfIrFTTMRmHlO0bsa8GknyXL8RNXxk9ZQaufXAz-UJpoKaZBvT6hJWREAzxoZ-rGnDPVaC3nlBCu3yPorFcTbbr0CBz2svbfGgAYLQl54lLQmUpxI8661AEe1rdOLqAyLIUb4ZiSbO65-PmIkdZWVPFHMdbpSv4GMNdvodleCWBfMAcG2C09v-LR6g
https://irecover-ca.cdn.ampproject.org/update-cache/c/s/irecover.ca/article?amp_action=flush&_ts=1581446499&_url_signature=KDaKbX0AbVbllwkTpDMFPOsFCRNw2sbk6Vd552bbG3u5QrecEmQ1SoMzmMR7iSXinO7LfM2bRCgJ1aD4y2cCayzrQuICrGz6b_PH7gKpo6tqETz06WmVeiP89xh_pBOu-pyN5rRHf0Pbu8oRkD2lRqgnGrLXDfIrFTTMRmHlO0bsa8GknyXL8RNXxk9ZQaufXAz-UJpoKaZBvT6hJWREAzxoZ-rGnDPVaC3nlBCu3yPorFcTbbr0CBz2svbfGgAYLQl54lLQmUpxI8661AEe1rdOLqAyLIUb4ZiSbO65-PmIkdZWVPFHMdbpSv4GMNdvodleCWBfMAcG2C09v-LR6g
However, this always results in the same error code from google.但是,这总是会导致来自 google 的相同错误代码。
Invalid public key due to ingestion error: 404 or 410 error from origin
由于摄取错误而导致公钥无效:来自源的 404 或 410 错误
Does anyone have any idea what I'm doing wrong?有谁知道我做错了什么?
A couple of things to check for apikey.pub accessibility:需要检查 apikey.pub 可访问性的几件事:
The /.well-known/amphtml/apikey.pub
file is accessible to both mobile and desktop user agents (eg no redirect for non-mobile as the AMP cache client may redirect) /.well-known/amphtml/apikey.pub
文件可被移动和桌面用户代理访问(例如,对于非移动设备没有重定向,因为 AMP 缓存客户端可能会重定向)
The public key is not excluded in robots.txt eg: robots.txt 中不排除公钥,例如:
User-agent: *
Allow: /.well-known/amphtml/apikey.pub
curl -I https://amp.example.com/.well-known/amphtml/apikey.pub
HTTP/2 200
date: Sun, 26 Jul 2020 23:48:55 GMT
content-type: text/plain
vary: Accept-Encoding
etag: W/"1c3-173478a8840"
last-modified: Sun, 26 Jul 2020 23:48:55 GMT
With those things in place, I get an "OK" success response from the update/cache endpoint有了这些东西,我从更新/缓存端点得到了一个“OK”的成功响应
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.