Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
您将希望使用这种类型的范例来获得最佳的用户体验。
AJAX 是您的朋友
仅发送向用户显示页面轮廓所需的最少信息。
然后在每个内容部分(您尚未加载)都有一个微调器。
在加载 javascript 时(为了清楚起见,我缩写了......请参阅 http://jQuery.com/ 有关其 ajax 调用的更多信息),您可以调用输出一些 JSON 的特定 php 页面。这是真正的工作发生并需要时间的地方。
然后在 displayFacebookContent 和 displayTwitterContent 回调函数中,您可以在此处动态构建 DOM 内容。
再次强调,这只是为了展示概念,您必须充实脚本并构建用 JSON 对象响应的 php 处理程序。
通过将艰苦的工作转移给 AJAX 处理程序,可以快速提供主要 HTML,并且用户会感到满意。当他的眼睛在页面上移动时,一些 AJAX 调用将完成,您将动态地将可用数据插入到 DOM 中,他们会看到它。
这有点像谷歌在您键入时进行的搜索,它会向服务器发出 AJAX 回调,并在您单击“提交”之前抓取内容以供您实时显示。
还研究应用程序级别和 Web 服务器级别的服务器端缓存。您还可以在网络级别进行一些缓存。
You will want to use this type of paradigm for getting the best user experience.
AJAX is your friend
Only send down the minimal information you need to get the outline of the page displayed to the user.
Then in each of the content sections (that you have yet to load) have a spinner.
In the loading of your javascript (I'm abbreviating for sake of clarity...see http://jQuery.com/ for more info on their ajax calls), you can make calls to specific php pages that spit out some JSON. This is where the real work happens and takes the time.
Then in the displayFacebookContent and displayTwitterContent callback functions, this is where you build the content for the DOM dynamically.
Again, this is abbreviated to show the concept, you will have to flesh out the scripting and also build the php handlers that respond with JSON objects.
By offloading the hard work to the AJAX handlers the main HTML is served down quickly and the user is happy. By the time his eyes move around the page, some of the AJAX calls will have completed and you'll have dynamically inserted useable data into the DOM and they'll see it.
It's kinda like google's search as you type, it's making an AJAX call back to the server and grabbing content for you to display in real time before you even click submit.
Also research into server-side caching at the application level as well as the webserver level. There's also some caching you can do at the network level too.
我对 Facebook 的内部结构已经不太熟悉了,但是有一些方法和技术可以实现这些事情:
I am not extremely familiar with the Facebook internals anymore but there are ways and technologies for these things:
在所有基础设施之间,他们使用 Cassandra、Memcached,用 C++ 等编译的 PHP。 此处是 Facebook 基础设施的完整描述。
Between all infrastructure, they use Cassandra, Memcached, PHP compiled in C++ and others. Here a complete description of Facebook infra.
最后我找到了解决方案。他们广泛使用缓存技术和 jQuery 历史记录插件,该插件支持历史记录,从而使其对搜索引擎友好。
可以在这里找到
http://itswadesh。 wordpress.com/2012/03/29/facebook-type-vertical-navigation-menu-created-with-jquery/
Finally i found out the solution. They use caching technology extensively with jQuery history plugin which enables history hence making it search engine friendly.
Can be found here
http://itswadesh.wordpress.com/2012/03/29/facebook-type-vertical-navigation-menu-created-with-jquery/