I have an iOS app that making API calls to 2 different servers (server A
and server B
) using Alamofire 5.2.2. Based on my understanding and what I read on StackOverflow, Alamofire should automatically set the If-None-Match
request header as long as the cache policy is set to .useProtocolCachePolicy
, and return status code 200
to the app if the server responded with status code 304
.
I am able to make an API call to server A
and Alamofire is setting the If-None-Match
header as expected. However, by using the same set of code, Alamofire is not setting the If-None-Match
header when I make API call to server B
.
One thing I notice is that server A
is using a strong validation:
Etag: "7266bc2f1b245365bb1a74da5185bca6"
Whereas, server B
is using a weak validation:
ETag: W/"6672-pKPf8kg1eUMH8msoW0et1yskcQQ"
I also tried to manually set the If-None-Match
header when calling server B
and the server responded with status code 304
. I was expecting Alamofire to return status code 200
to my app, instead, it returns status code 304
.
Any idea why Alamofire does not automatically set the If-None-Match
when making API call to server B
? Is that an Alamofire bug or just a server config issue? Anything I can do to get the same behavior as making API call to server A
?
Thanks in advance.
Apparently, the reason for my problem is because server B
has the response header Cache-Control = no-store
and Alamofire is respecting this header and ignore the given Etag.