Add cache timeout

This commit is contained in:
Pieter Vander Vennet 2021-04-17 15:42:22 +02:00
parent 823768bbc9
commit 576fd8ff40
5 changed files with 30 additions and 1 deletions

View file

@ -42,6 +42,10 @@ export default class LayoutConfig {
public readonly enableGeolocation: boolean;
public readonly enableBackgroundLayerSelection: boolean;
public readonly customCss?: string;
/*
How long is the cache valid, in seconds?
*/
public readonly cacheTimeout?: number;
private readonly _official: boolean;
constructor(json: LayoutConfigJson, official = true, context?: string) {
@ -167,6 +171,7 @@ export default class LayoutConfig {
this.enableAddNewPoints = json.enableAddNewPoints ?? true;
this.enableBackgroundLayerSelection = json.enableBackgroundLayerSelection ?? true;
this.customCss = json.customCss;
this.cacheTimeout = json.cacheTimout ?? (60 * 24 * 60 * 60)
}
public CustomCodeSnippets(): string[] {

View file

@ -118,6 +118,25 @@ export interface LayoutConfigJson {
* The id of the default background. BY default: vanilla OSM
*/
defaultBackgroundId?: string;
/**
* The number of seconds that a feature is allowed to stay in the cache.
* The caching flow is as following:
*
* 1. The application is opened the first time
* 2. An overpass query is run
* 3. The result is saved to local storage
*
* On the next opening:
*
* 1. The application is opened
* 2. Data is loaded from cache and displayed
* 3. An overpass query is run
* 4. All data (both from overpass ánd local storage) are saved again to local storage (except when to old)
*
* Default value: 60 days
*/
cacheTimout?: number;
/**