fix: IndexNow hears of deleted and edited records
RecordDeleted marks the listed rows it excludes and RecordSaved the rows whose lastmod it moves (indexnow_pending_at); the next rebuild sends them to IndexNow as removed or changed and clears the marks. RecordSaved checks for a nil event before reading it. TestIndexNow now deletes and edits through the record events, as the admin does.
This commit is contained in:
@@ -129,7 +129,7 @@ The News sources setting (`news_sources`) narrows the list. It takes the values
|
||||
[IndexNow](https://www.indexnow.org/documentation) tells Bing, Yandex and the other participating engines about changed addresses at once; Google does not use it.
|
||||
|
||||
- **Key.** Saving the settings with IndexNow on generates a key of 32 hex characters from `crypto/rand` (`classes.GenerateKey`, `classes.EnsureKey`). The "Generate a new key on save" checkbox (`indexnow_new_key`, no column) replaces it, and the old key file answers 404 at once. The key file `<key>.txt` is served at `/_sitemap/indexnow/<key>.txt` and belongs at the site root, which covers every address of the host, so no `keyLocation` is sent.
|
||||
- **Notifications.** After a rebuild commits, in the `production` environment only, with IndexNow on, a key and a site address, `classes.NotifyIndexNow` queues the conga job `golem15.sitemap.indexnow` (`classes.IndexNowArgs`) with the added, changed and removed addresses on the site's host, at most 10 000 per job. The job (`classes.SendIndexNow`) posts `{host, key, urlList}` to `https://api.indexnow.org/indexnow` through a `fetchguard` client that may reach only that host (HTTPS, no redirects, 10 s), never an address of another host.
|
||||
- **Notifications.** After a rebuild commits, in the `production` environment only, with IndexNow on, a key and a site address, `classes.NotifyIndexNow` queues the conga job `golem15.sitemap.indexnow` (`classes.IndexNowArgs`) with the added, changed and removed addresses on the site's host, at most 10 000 per job. A record deleted in the admin (`pact.RecordDeleted`) is sent as removed and a content edit that keeps the address (`pact.RecordSaved` moving its lastmod) as changed: the listeners mark the rows (`indexnow_pending_at`) and the next rebuild sends and clears them; outside production the marks are cleared without a notification. The job (`classes.SendIndexNow`) posts `{host, key, urlList}` to `https://api.indexnow.org/indexnow` through a `fetchguard` client that may reach only that host (HTTPS, no redirects, 10 s), never an address of another host.
|
||||
- **Answers.** 200 and 202 are success. Every answer is recorded (`indexnow_last_at`, `indexnow_last_count`, `indexnow_last_status`). 400, 403 and 422 are not retried; 429 and 5xx answers and network errors fail the job, which retries up to five times.
|
||||
- **Status.** The IndexNow tab's status partial shows the key and its public address (or that a key is generated on save), the last notification (or that none was sent), and a callout after a 403 (the engines could not read the key file), a 422 (the addresses do not match the site address) or a 429 (with the next attempt's time while a retry is queued).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user