Trending

World technology news

→
Finding an older station notice with the 2013 Memento protocol
Software Engineering · 2013
Software Engineering2013

Finding an older station notice with the 2013 Memento protocol

Model the live station notice, datetime negotiation and archived copies as separate HTTP resources. Test the archive boundary, redirect and returned capture time against a deliberately small timetable.

Archive retrospective · Topic year 2013

Developer's JournalPublished: Dec 4, 20266 min read
Reading progress0%
In this article
  1. The address of an earlier notice
  2. Requested and observed times
  3. Running the two-platform fixture
  4. Shared caches and review evidence
  5. From two captures to a public collection

The address of an earlier notice

An afternoon update to a railway notice sends passengers to a different platform. A complaint filed that evening can raise a distinct question: what could a passenger have read at noon? The current notice may still live at its usual address, while earlier bodies are stored elsewhere. A crawler may also have missed an edit between two captures. The train event, the operator’s edit and the archival capture represent three different times. RFC 7089, published as an Informational RFC in December 2013, gives HTTP applications a vocabulary and request flow for retrieving past states. The live notice is the Original Resource. A TimeGate handles datetime negotiation. Each Memento identifies an archived state, and a TimeMap can list known captures for the original. Distinct endpoints are convenient when a researcher needs to cite a particular capture, revisit it later and see how it was obtained.

Requested and observed times

The Accept-Datetime field expresses the state a client is looking for. The station example selects the latest capture at or before the requested instant. With captures at 08:00 and 14:30 UTC, noon is resolved to 08:00. This is a local archive rule chosen for a review of information available at the time. A different archive can choose what it presents and should explain the distance between the request and the returned representation. The example's TimeGate sends a Location pointing at a capture. Opening that address returns Memento-Datetime, which identifies when the archived representation was captured. A user interface can display both times and the capture address. It should convey the gap explicitly. A noon request that yields the morning snapshot cannot establish that the same text remained visible throughout the interval. That claim would require additional evidence about the operator's edits.

Application flowConceptual sketch · summary of the article's technical flow

Running the two-platform fixture

The script starts a loopback HTTP server, exposes the live notice and TimeGate, and follows the chosen capture using a second request. The live notice advertises the gate using a Link field. The test handles the redirect manually to inspect the initial response separately from the selected representation. It observes a 404 at 07:00, a redirect to the 08:00 capture reading Platform 2 for a noon query, and a redirect to the 14:30 capture reading Platform 4 for a 15:00 query. Each request inspects Vary. The redirects lack Memento-Datetime, and the follow-up requests read it at the capture addresses. We ran the fixture on Node.js 24.19.0. It uses a single negotiation pattern, two known captures and three GET requests to the gate. This verifies the fixture’s selection and headers. Testing all RFC examples, older servers and a public archive requires additional cases.

import assert from 'node:assert/strict';
import {createServer} from 'node:http';

const captures=[
 {at:'2013-12-03T08:00:00Z', notice:'Platform 2'},
 {at:'2013-12-03T14:30:00Z', notice:'Platform 4'}
];
const date=x=>new Date(x).toUTCString();
const server=createServer((req,res)=>{
 const path=req.url;
 if(path==='/notice'){
  res.writeHead(200,{link:'</timegate>; rel="timegate"'}).end('Current timetable');
  return;
 }
 if(path==='/timegate'){
  const requested=Date.parse(req.headers['accept-datetime']);
  const index=captures.findLastIndex(c=>Date.parse(c.at)<=requested);
  if(index<0){res.writeHead(404,{vary:'accept-datetime'}).end();return;}
  res.writeHead(302,{location:'/archive/'+index,vary:'accept-datetime',link:'</notice>; rel="original"'}).end();
  return;
 }
 const capture=path==='/archive/0'?captures[0]:path==='/archive/1'?captures[1]:null;
 if(!capture){res.writeHead(404).end();return;}
 res.writeHead(200,{'memento-datetime':date(capture.at),link:'</notice>; rel="original", </timegate>; rel="timegate"'}).end(capture.notice);
});
server.listen(0,'127.0.0.1');
await new Promise(ok=>server.once('listening',ok));
try{
 const root='http://127.0.0.1:'+server.address().port;
 const original=await fetch(root+'/notice');
 assert.match(original.headers.get('link'),/rel="timegate"/u);
 const observed=[];
 for(const at of ['2013-12-03T07:00:00Z','2013-12-03T12:00:00Z','2013-12-03T15:00:00Z']){
  const gate=await fetch(root+'/timegate',{headers:{'accept-datetime':date(at)},redirect:'manual'});
  assert.equal(gate.headers.get('vary'),'accept-datetime');
  if(gate.status===404){observed.push([at,404]);continue;}
  assert.equal(gate.status,302);
  assert.equal(gate.headers.get('memento-datetime'),null);
  const memento=await fetch(root+gate.headers.get('location'));
  assert.equal(memento.status,200);
  observed.push([at,302,memento.headers.get('memento-datetime'),await memento.text()]);
 }
 assert.deepEqual(observed.map(r=>r.at(-1)),[404,'Platform 2','Platform 4']);
 console.log(JSON.stringify({node:process.version,observed},null,2));
}finally{await new Promise(ok=>server.close(ok));}

Shared caches and review evidence

At a single TimeGate URL, a noon request and an evening request can produce different Location values. An intermediate cache that ignores the request's datetime could reuse a redirect that points to a plausible but incorrectly selected copy. Vary identifies this negotiation dimension. A production check should exercise two requests through the same actual proxy or CDN and compare their Locations and final capture times. The fixture checks field values on an origin response and contains no intermediate cache. The capture URL is intended for a different job: it identifies a selected archived state so another reader can open it without negotiating again. A review record that keeps the requested time, returned capture time, Original Resource URL and final address can be replayed when the TimeGate’s selection policy changes. Archive retention and access controls still determine how long that evidence can be retrieved.

From two captures to a public collection

For a larger collection, first inspect its coverage and document gaps between captures. A recent successful archive job tells you about that run, while prior dates require their own records. A TimeMap makes known copies discoverable and introduces practical choices about ordering, pagination and duplicates. Include station identity and language in your archive model so requests cannot silently switch between notices about two locations. Cover the exact 08:00 boundary, values before the oldest and after the newest capture, and an invalid date in separate tests. The sample returns a 404 for a lookup before the first capture. Explain that outcome to the reader as an archive coverage issue, since the original resource may still exist. For an audit, preserve enough evidence to read the selected document again and distinguish when the operator published it from when the crawler observed it.

623 reads ✎ Write a comment

Reader discussion

Discussion prompt

Which data would you verify before applying this development in your field?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.