【发布时间】:2019-02-23 14:05:20
【问题描述】:
我尝试在我的服务人员中缓存 http 请求。但我只能将最后一个请求缓存到特定的 URL。
据我了解,它应该缓存最后 100 个响应 (maxSize: 100)。 Http-Request 始终具有相同的 URL(例如:./player/example),并且所有请求的 Http-Header 都不同。
这是我的ngsw-conf:
"dataGroups": [{
"name": "api-freshness",
"urls": [
"/player/**"
],
"cacheConfig": {
"maxSize": 100,
"maxAge": "1h",
"timeout": "3s",
"strategy": "freshness"
}
}]
【问题讨论】:
-
这似乎很正确。因为您可能会缓存您的回复,例如
cache.put(request, response)(请注意,只有 GET 请求)。
标签: angular service-worker angular-service-worker