Skip to content

Configuring Memento

Ruben Taelman edited this page Apr 8, 2020 · 8 revisions

This documentation is based on LDF Server 2.x.x. Please refer to @ldf/feature-memento for updated documentation for the latest LDF server version.

The Linked Data Fragments server supports the Memento Protocol. If your Linked Data source evolve over time and has multiple versions, it makes access and query across the various versions straightforward. To enable the Memento Protocol, follow the guide below.

Add Memento datasources

Any data source can be configured as a Memento resource, meaning it represents a prior version of an existing data source. This is done by adding a memento property to any datasource in your config file. This property has an interval property, containing an array of start and end timestamps in which this memento was valid. Each timestamp must be in ISO 8601 format.

For example, the datasources dbpedia_2015 and dbpedia_2014 are mementos of DBpedia valid in 2014 and 2015:

  "datasources": [
    {
      "@id": "ex:dbpedia_2015",
      "@type": "HdtDatasource",
      "datasourceTitle": "DBpedia v2015",
      "description": "DBpedia v2015 with an HDT back-end",
      "datasourcePath": "dbpedia_2015",
      "hdtFile": "/data1/dbpedia/cdata_2015.hdt"
    },
    {
      "@id": "ex:dbpedia_2014",
      "@type": "HdtDatasource",
      "datasourceTitle": "DBpedia v2014",
      "description": "DBpedia v2014 with an HDT back-end",
      "datasourcePath": "dbpedia_2014",
      "hdtFile": "/data1/dbpedia/cdata_2014.hdt"
    }
  ],

  "mementos": [
    {
      "versions": [
        {
          "mementoDatasource": "ex:dbpedia_2015",
          "versionStart": "2014-09-14T11:59:59Z",
          "versionEnd": "2015-04-15T00:00:00Z"
        },
        {
          "mementoDatasource": "ex:dbpedia_2014",
          "versionStart": "2013-06-15T11:59:59Z",
          "versionEnd": "2014-09-15T00:00:00Z"
        }
      ]
    }
  ]

Add an Original Resource

You can promote a data source to serve Original Resources by attaching it to a Timegate. This indicates to the LDF server that there are mementos available to this datasource. Simply add timegate: true to the datasource configuration. The LDF server will then use the information provided in the timegates section (see below) to build the appropriate Memento responses.

For example, the following datasource named dbpedia is the current version or in Memento terms, the Original.

"dbpedia": {
    "title":       "DBpedia 2015",
    "description": "DBpedia 2015 with an HDT back-end",
    "type":        "HdtDatasource",
    "settings":    {
      "file": "/data1/dbpedia/cdata_2015.hdt"
    },
    "timegate": true
  },

Add a timegate

To connect an Original Resource to its Mementos, you need to configure a Timegate. Therefore, add a new section called timegates. This section contains a subsection mementos, which lists all the versions (aka Mementos) per datasource. The LDF server uses this information to connect a particular datasource with its versions, and also to build the appropriate Memento URL. The route where the Timegates are located can be customised by setting baseURL.

For example, the timegates section below links 2 versions dbpedia_2014 and dbpedia_2015 with the datasource dbpedia:

"timegates": {
  "baseURL": "/timegate/",
  "mementos": {
    "dbpedia": {
      "versions": [
        "dbpedia_2015",
        "dbpedia_2014"
      ]
    }
  }
}

In case the Original Resource is hosted externally, you can specify the mementoBaseURL to reconstruct its URL. If mementoBaseURL is not set, the URL is automatically constructed from the server's baseURL and the specified datasource.

"timegates": {
  "baseURL": "/timegate/",
  "mementos": {
    "dbpedia": {
      "originalBaseURL": "http://fragments.dbpedia.org/2015/en",
      "versions": [
        "dbpedia_2015",
        "dbpedia_2014"
      ]
    }
  }
}

Example: DBpedia TPF archive

The Memento DBpedia LDF Server supports about 10 versions of DBpedia starting from 2007. A Memento Client like Memento for Chrome can be used to navigate the versions in a browser. The command line utility, cUrl, can also be used to see Memento in action.

$ curl -iL -H "Accept: text/turtle; Accept-Datetime: Wed, 15 Apr 2013 00:00:00 GMT" http://fragments.mementodepot.org/timegate/dbpedia?subject=http%3A%2F%2Fdbpedia.org%2Fresource%2FEnglish

HTTP/1.1 200 OK
Content-Type: text/turtle;charset=utf-8
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept-Datetime
Access-Control-Expose-Headers: Content-Location,Link,Memento-Datetime
Link: <http://fragments.dbpedia.org/en?subject=http%3A%2F%2Fdbpedia.org%2Fresource%2FEnglish>;rel=original, <http://fragments.mementodepot.org/timegate/dbpedia?subject=http%3A%2F%2Fdbpedia.org%2Fresource%2FEnglish>;rel=timegate
Vary: Accept, Accept-Datetime
Content-Location: http://fragments.mementodepot.org/dbpedia_201510?subject=http%3A%2F%2Fdbpedia.org%2Fresource%2FEnglish
Memento-Datetime: Thu, 01 Oct 2015 00:00:00 GMT

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
...

Note that due to a CORS issue, the timegate returns 200 style negotiation instead of the preferred 302 style.

Through the additional service http://dbpedia.mementodepot.org/, we also continue to support DBpedia subject pages. The following example queries the Memento LDF TimeGate to retrieve a Memento of the English DBpedia page around 15 March 2015.

$ curl -IL -H "Accept-Datetime: Wed, 15 Apr 2015 00:00:00 GMT" http://dbpedia.mementodepot.org/timegate/http://dbpedia.org/page/English

HTTP/1.1 302 Found
Date: Tue, 15 Mar 2016 21:07:08 GMT
Location: http://dbpedia.mementodepot.org/memento/20150415000000/http://dbpedia.org/page/English
Vary: accept-datetime
Link: <http://dbpedia.org/page/English>; rel="original",<http://dbpedia.mementodepot.org/timemap/link/http://dbpedia.org/page/English>; rel="timemap"; type="application/link-format",<http://dbpedia.mementodepot.org/memento/20150415000000/http://dbpedia.org/page/English>; rel="memento"; datetime="Wed, 15 Apr 2015 00:00:00 GMT"

HTTP/1.1 200 OK
Date: Tue, 15 Mar 2016 21:07:08 GMT
Content-Type: text/html
Link: <http://dbpedia.org/page/English>; rel="original", <http://dbpedia.mementodepot.org/memento/20150415000000/http://dbpedia.org/page/English>; rel="memento"; datetime="Wed, 15 Apr 2015 00:00:00 GMT", <http://dbpedia.mementodepot.org/timegate/http://dbpedia.org/page/English>; rel="timegate", <http://dbpedia.mementodepot.org/timemap/link/http://dbpedia.org/page/English>; rel="timemap"
Memento-Datetime: Wed, 15 Apr 2015 00:00:00 GMT