我正在看以下苹果示例源代码:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
}
Run Code Online (Sandbox Code Playgroud)
试图找出:
为什么要使用static关键字?
如果在每次调用方法时将其设置为nil,这相当于缓存变量.
代码来自Tableview Suite演示中的示例4
RFC似乎建议客户端永久缓存响应:http: //www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
10.3.2 301永久移动
已为所请求的资源分配了一个新的永久URI,并且此资源的任何将来的引用应该使用返回的URI之一.具有链接编辑功能的客户端应尽可能自动将对Request-URI的引用重新链接到服务器返回的一个或多个新引用.除非另有说明,否则该响应是可缓存的.
新的永久URI应该由响应中的Location字段给出.除非请求方法是HEAD,否则响应的实体应该包含一个带有指向新URI的超链接的短超文本注释.
如果收到301状态代码以响应GET或HEAD以外的请求,则用户代理不得自动重定向请求,除非用户可以确认,因为这可能会改变发出请求的条件.
Run Code Online (Sandbox Code Playgroud)Note: When automatically redirecting a POST request after receiving a 301 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request.
我很难找到任何主要浏览器的具体浏览器文档,说明他们如何处理这些.
我已经开始挖掘firefox的源代码,但很快就迷路了.
对于哪些(如果有的话)浏览器,以下情况是否属实,并且是否有适用于Firefox或IE的权威文档?:
第一次:
任何后续时间:
firefox internet-explorer webclient behavior http-status-code-301