I have a rule, triggered by After saving new content, with the goal of pinging the Internet Archive to grab a copy of any newly-posted node (based on the documentation here), that looks like this:

{ "rules_notify_internet_archive" : {
    "LABEL" : "Notify Internet Archive",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_http_client" ],
    "ON" : { "node_insert" : [] },
    "DO" : [
      { "request_url" : {
          "USING" : {
            "url" : "http:\/\/web.archive.org\/save\/[node:url]",
            "headers" : "Accept: application\/json",
            "method" : "GET"
          },
          "PROVIDE" : { "http_response" : { "http_response" : "HTTP data" } }
        }
      }
    ]
  }
}

While the action is being triggered properly, and the REST request is being made to web.archive.org, because of the timing of the process, it's archiving a 404 page. When I look in my Apache logs I see:

207.241.226.233 [26/Jan/2017:21:37:14 +0000] "GET /sample-content-2 HTTP/1.1" 404 13642 "-" "Drupal (+http://drupal.org/)"
142.163.206.40 [26/Jan/2017:21:37:15 +0000] "GET /sample-content-2 HTTP/1.1" 200 66319 "https://ruk.ca/node/add/article" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0"

So what's happening is that the action to notify The Internet Archive is happening, causing the Internet Archive to immediately crawl the page (at 21:37:14), but it's getting a 404 in response; one second later, at 21:37:15, when my browser loads the newly-saved page, it's 200.

I assume this means that the action got triggered not "After saving new content" but "just a second before saving new content."

If I'm correct, is there an easy way around this?

Comments

reinvented created an issue.