Was there ever a proposal to include the URL fragment into the HTTP request?

不羁岁月 提交于 2019-12-23 04:08:44

问题


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.

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.

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.


回答1:


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.




回答2:


Webkit Bug 24175 - URL Redirect Loses Fragment refers to Handling of fragment identifiers in redirected URLs which may be of interest.

A suggestion for a future version of HTTP may be to add an (optional) Fragment header to the request, which holds the fragment identifier.

Even simpler may be to allow an HTTP request to contain a fragment identifier.




回答3:


Imho, the fragment identifier really is not a good place to store the state, it has been designed for something else.

That being said, http://www.jenitennison.com/blog/node/154 has a good discussion of the whole subject.



来源:https://stackoverflow.com/questions/5738627/was-there-ever-a-proposal-to-include-the-url-fragment-into-the-http-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!