HTTP'HEAD'动词在Web开发中是否有用? [英] Is the HTTP 'HEAD' verb useful in web development?

查看:154
本文介绍了HTTP'HEAD'动词在Web开发中是否有用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读关于'HEAD'动词的w3.org规范,我想我错过了什么。我看不出它会如何有用。

I've read the w3.org spec on the 'HEAD' verb, and I guess I'm missing something. I can't see how it would be useful.

HTTP'HEAD'动词在网页开发中是否有用?

如果怎么样?

推荐答案

来自 RFC2616


此方法(HEAD)可用于获取
关于实体
的元信息,请求没有
转移实体主体本身。
此方法通常用于测试
超文本链接的有效性,
可访问性和最近的
修改。

This method (HEAD) can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

HEAD优先于GET的原因是由于响应中缺少消息体,因此在您想要确定内容是否已发生更改的情况下使用它 - 最后一次更改修改时间或内容长度通常表示这一点。

The reason why HEAD is preferred to GET is due to the absence of the message body in the response making it using in scenarios where you want to determine if the content has changed at all - a change in the last modified time or content length usually signifies this.

此外,HEAD请求将提供有关服务器设置的一些信息(无论是IIS / Apache等),除非服务器被掩盖;当然,这在所有回复中都可用,但是当您不知道响应的大小时,HEAD是首选。 HEAD也是确定网站是上升还是下降的最简单方法;再次,消息体的无关性使得HEAD成为理想的候选者。

Also, a HEAD request will provide some information about the server setup (whether it is IIS/Apache etc.), unless the server was masked; of course, this is available in all responses, but HEAD is preferred especially when you don't know the size of the response. HEAD is also the easiest way to determine if a site is up or down; again the irrelevance of the message body makes HEAD the ideal candidate.

我不确定这一点,但RSS / ATOM提要读者会使用HEAD而不是GET来确定是否Feed的内容已经改变。

I'm not sure about this, but RSS/ATOM feed readers would use HEAD over GET to ascertain if the contents of the feed have changed.

这篇关于HTTP'HEAD'动词在Web开发中是否有用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆