Class LifetimesService

public

A basic LifetimesService that can be added to the Store service.

Determines staleness based on time since the request was last received from the API using the date header.

This allows the Store's CacheHandler to determine if a request is expired and should be refetched upon next request.

The Fetch handler provided by @ember-data/request/fetch will automatically add the date header to responses if it is not present.

Usage:

1
2
3
4
5
6
7
8
9
10
11
import { LifetimesService } from '@ember-data/request-utils';
import DataStore from '@ember-data/store';

// ...

export class Store extends DataStore {
  constructor(args) {
    super(args);
    this.lifetimes = new LifetimesService(this, { apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
  }
}