有没有建议将URL片段包含在HTTP请求中? [英] Was there ever a proposal to include the URL fragment into the HTTP request?

查看:139
本文介绍了有没有建议将URL片段包含在HTTP请求中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前的HTTP规范中,URL片段(URL的一部分包括之后)不会以任何方式发送到服务器。然而,随着AJAX的扩散,它使用片段来维护某种形式的状态,在很多情况下服务器在请求时知道URL片段会很有用。

In the current HTTP spec, the URL fragment (the part of the URL including and following the #) is not sent to the server in any way. However with the increased spread of AJAX, which uses the fragment to maintain some form of state, there are a lot of situations where it would be useful for the server to have knowledge of the URL fragment at request time.

例如,如果你去 http://facebook.com ,然后点击一下您的信息流中的用户名,该网址将成为 http://faceboook.com/#!/username - 允许FB在不重新加载所有引导程序JS和HTML的情况下更新页面。但是,如果您要使用浏览器重新加载,服务器将无法看到URL的#/!username部分,因此无法为您预先呈现内容。这会强制您的浏览器在客户端Javascript加载并解析片段后发出额外请求。

For example, if you go to http://facebook.com, then click a user name in your stream, the URL will become http://faceboook.com/#!/username - to allow FB to update your page without reloading all of its bootstrap JS and HTML. However, if you were to reload this with your browser, the server would have no way of seeing the "#/!username" part of the URL, and therefore could not pre-render the content for you. This forces your browser to make an extra request once the client Javascript has loaded and parsed the fragment.

我想知道是否有任何努力或建议来创建标准实现这一目标的机制。

I am wondering if there have been any efforts or proposals towards creating a standard mechanism to achieve this.

例如,可能有一个标准的HTTP标头,它将与URL片段的值一起发送 - 任何关心此类事情的服务器然后可以访问它。

For example, there could be a standard HTTP header, which would be sent with the value of the URL fragment - any server which cared about such things could then have access to it.

对于整个网络应用程序社区来说,这似乎是一个非常有用的东西,所以我很惊讶没有听到任何建议。也许我错过了它。

It seems like this would be a very useful thing for the web-application community as a whole, so I am surprised to not have heard anything proposed. Perhaps I missed it though.

推荐答案

我找到了

I found this proposal by Google to make Ajax pages crawlable, but it addresses a more constrained set of use cases. Specifically, it creates a way to replace the URL fragment with a URL parameter to obtain the same HTML output from the server as would be generated by a client visiting the equivalent URL with the fragment. However, such URLs are useless for actually running the Ajax apps, since they would necessitate a page reload every time.

这篇关于有没有建议将URL片段包含在HTTP请求中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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