0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CloudflareからIndexNowに更新が送信されない問題

0
Posted at

以前の投稿「Cloudflareを使っているサイトでIndexNowを有効にする方法」でCloudflareからIndexNowに、更新通知を送る設定を紹介しましたが、画像や音声ファイルなどの静的ファイルの更新ばかりが通知されて、肝心の記事ページの更新が通知されていないことに、気が付きました。

原因

Cloudflareのキャッシュが更新されたタイミングで、IndexNowに通知が行われるようです。Node.jsのExpressなどで、記事ページを動的に生成している場合、記事ページはキャッシュされないので、そもそも更新の通知が発生していませんでした。

解決策

Cloudflareの機能では更新通知を送れないので、記事の更新通知は手動で行います。

APIキーは英数字の羅列32文字程度を適当に決めます。ここでは仮に API_KEY_TEXT と表記しておきます。

サイトのルートにAPIキーのテキストファイルを作成して配置します。
/API_KEY_TEXT.txt

API_KEY_TEXT

サイトの更新時にcurlなどのコマンドで更新通知を送ります。urlListには更新したページのURLを書きます。

curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{
  "host": "サイトのドメイン",
  "key": "API_KEY_TEXT",
  "keyLocation": "https://サイトのドメイン/API_KEY_TEXT.txt",
  "urlList": [
    "https://yourdomain.com/",
    "https://yourdomain.com/page1",
    "https://yourdomain.com/page2"
  ]
}' https://api.indexnow.org/indexnow
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?