Alamofire GET If-None-Match由于某种原因不起作用

时间:2016-02-18 08:39:18

标签: ios alamofire

如果我使用SQL> explain plan for select * from dual where dummy like 'X'; Explained. SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------- Plan hash value: 272002086 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 | -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------- 1 - filter("DUMMY"='X') 13 rows selected. SQL> 和标题HEAD并且ETag在服务器上没有更改,我会得到304响应(这很棒)。如果我使用相同的标题,但"If-None-Match":ETag,我得到200响应。这是两个代码,也许有人会发现我的错误:

GET
编辑:有趣的事情刚刚发生 - 我今天第一次运行应用程序,两个都给了我304,第二次GET给了200,HEAD 304。

1 个答案:

答案 0 :(得分:1)

试试这个:

Xcode 8.1,Swift 3,Alamofire 4.0

var urlRequest = URLRequest(url: useURL)
urlRequest.addValue(ETag, forHTTPHeaderField: "If-None-Match")
urlRequest.cachePolicy = .reloadIgnoringCacheData

Alamofire.request(urlRequest).response { result in // method defaults to .get
  print(result.response?.statusCode) //Optional(304)
}