Closed manzapanza closed 4 years ago
Hi @manzapanza !
I just checked, HttpCacheService stores the whole HttpResponse object and returns it when cache is hit (have a look at http-cache.service.ts)
// ERROR TypeError: data.httpResponse.headers.keys is not a function
seems to not be the same code as in your method 'getApartments()'
Yes but it don't works because the response headers are not an object but are inside a function. To read an header you need to call response.headers.get(key)
and not simply by response.headers[key]
. If you look at the cache stored (in my case is localStorage) ther's not headers stored there:
So, in my opinion we should store headers inside the cache as as a plain key/value object and when restore the HttpResponse, restore also the HttpHeaders and pass here as second parameter:
This seems indeed a bug, thanks also for providing a PR to fix it. Though, I have to be honest on this one and we were discussing recently about removing the cache service entirely, in favor of integration of state management libraries.
Still, I'm willing to merge the fix in the meantime, and we are still open to feedbacks whether what we should do ;)
Dropping this one as cache service will be removed in next version (#534)
I'm submitting a...
Current behavior
The HttpClient cache doesn't store and returns http headers response. When the request cache is empty the headers are returned, when the response come from cache no one header is returned.
Expected behavior
All headers should be stored in the cache and returned
Minimal reproduction of the problem with instructions
Environment
Others: