diff --git a/topdown/http.go b/topdown/http.go index 0b5c16870a7..92570444f76 100644 --- a/topdown/http.go +++ b/topdown/http.go @@ -841,7 +841,11 @@ func (c *interQueryCache) checkHTTPSendInterQueryCache() (ast.Value, error) { headers, err := parseResponseHeaders(cachedRespData.Headers) if err != nil { - return nil, err + if forceCaching(c.forceCacheParams) { + headers = &responseHeaders{} + } else { + return nil, err + } } // check with the server if the stale response is still up-to-date. @@ -864,11 +868,16 @@ func (c *interQueryCache) checkHTTPSendInterQueryCache() (ast.Value, error) { } } - expiresAt, err := expiryFromHeaders(result.Header) - if err != nil { - return nil, err + if forceCaching(c.forceCacheParams) { + createdAt := getCurrentTime(c.bctx) + cachedRespData.ExpiresAt = createdAt.Add(time.Second * time.Duration(c.forceCacheParams.forceCacheDurationSeconds)) + } else { + expiresAt, err := expiryFromHeaders(result.Header) + if err != nil { + return nil, err + } + cachedRespData.ExpiresAt = expiresAt } - cachedRespData.ExpiresAt = expiresAt cachingMode, err := getCachingMode(c.key) if err != nil {