Improve caching mechanism for rookeries-app component.
This commit is contained in:
parent
4cda6719e8
commit
ca1cd16ca5
|
@ -17,7 +17,7 @@ const DEFAULT_CACHE_LIMIT = 5 * 60 * 1000;
|
||||||
|
|
||||||
export class RookeriesApp extends HTMLElement {
|
export class RookeriesApp extends HTMLElement {
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
return ["title", "cacheLimit"];
|
return ["title", "cache-limit"];
|
||||||
}
|
}
|
||||||
|
|
||||||
static get tagName() {
|
static get tagName() {
|
||||||
|
@ -83,7 +83,7 @@ export class RookeriesApp extends HTMLElement {
|
||||||
? storedContent.fetchedOn
|
? storedContent.fetchedOn
|
||||||
: new Date();
|
: new Date();
|
||||||
const elapsedTime = new Date() - storedContentFetchTime;
|
const elapsedTime = new Date() - storedContentFetchTime;
|
||||||
const cachedTimeDiff = this.getAttribute("cacheLimit") || DEFAULT_CACHE_LIMIT;
|
const cachedTimeDiff = this.getAttribute("cache-limit") || DEFAULT_CACHE_LIMIT;
|
||||||
|
|
||||||
if (!storedContent || (storedContent && elapsedTime > cachedTimeDiff)) {
|
if (!storedContent || (storedContent && elapsedTime > cachedTimeDiff)) {
|
||||||
this.fetchPageContent(currentPage).then(() => {
|
this.fetchPageContent(currentPage).then(() => {
|
||||||
|
|
Loading…
Reference in New Issue