304-NOT MODIFIED

某一天,我发现用开发工具查看资源的时候。看到CSS和PNG都显示304-Modified,于是我就清除了一下数据,然后刷新的时候,又回到了200-ok的状态。这应该就是把这些资源缓存起来了,有利也有弊。

“Hypertext Transfer Protocol — HTTP/1.1″, provides functionality for conditional GET requests. For example, an HTTP client can specify an If-Modified-Since HTTP header that consists of a time and date stamp, which tells the server that it has a cached copy of the content being requested. If the request meets the condition specified in the If-Modified-Since header, the server will not return a body, but will return the 304-Not Modified result.

大概的意思就是请求数据后,会从服务端发一个带有时间和时间戳的Http header包过来。如果这些资源已经存在,则不需要重新下载一次。显示状态为304-Modified。