简体   繁体   English

是更好的加载Twitter发布客户端或服务器端?

[英]Is better load Twitter posts client-side or server-side?

A website in C# and jQuery will read the last post from a Twitter timeline and shows it. C#jQuery一个网站将阅读Twitter时间轴上的最后一篇文章并进行展示。

I've found many plugins for jQuery (like Tweet!, Juitter, jQuery for Twitter, etc) and currently I'm using Juitter to do it. 我发现了许多jQuery插件(如Tweet!,Juitter,Twitter的jQuery等),目前我正在使用Juitter来实现它。 But I'm thinking whether this client-side approach is the best, since search crawlers will not read this content because it's JavaScript dependent . 但我在想这种客户端方法是否是最好的,因为搜索爬虫不会读取这些内容,因为它依赖于JavaScript

On the other hand, loading on the Page_Load could be a overhead to the server, since it will be waiting the Twitter response before sending the HTML back. 另一方面,在Page_Load上加载可能是服务器的开销,因为它将在发回HTML之前等待Twitter响应。 Unless there is any way better than I thought... 除非有任何比我想象的更好的方式......

Someone like one of these alternatives or suggest any other? 有人喜欢这些替代方案之一或建议任何其他?

EDIT 编辑

Just to clarify, I will haven't live updates after the post is loaded and shown. 只是为了澄清一下,在帖子加载并显示后我将没有实时更新。

Also I'm thinking if I could create some kind of cache on C# and only do requests to Twitter API again if a new post is written. 另外我想是否可以在C#上创建某种缓存,并且如果写了新帖子,只会再次向Twitter API发出请求。 This could be done? 这可以做到吗?

I'd put the functionality on the client. 我将功能放在客户端上。 Putting it in your C# code really isn't giving you any benefits - except maybe in SOE - which there might be a way around (or not - I'm not that knowledgeable in SOE land). 把它放在你的C#代码中真的没有给你带来任何好处 - 除了可能在SOE中 - 可能有一种方法(或者不是 - 我不是那么知情的SOE土地)。

Aside from SOE... these are what I can think of this late on Friday. 除了国有企业......这些是我在周五晚些时候能想到的。

Pros to Client Side: 客户方面的优点:

  1. The client will be able to load faster - which is always better. 客户端将能够加载更快 - 这总是更好。 If twitter is slow, you can manage the GUI with scripting rather than forcing a trip to the server. 如果twitter很慢,您可以使用脚本管理GUI,而不是强制访问服务器。
  2. It takes away from your server doing a lot of the work 它会使您的服务器完成大量工作
  3. Less internet clutter - yes one day we will be taxed on this! 减少网络混乱 - 是的,有一天我们将对此征税!
  4. The appearance of quickness. 外观速度快。 Even if it's the same speed as having it on the server, it usually appears faster - which in users eye's is better. 即使它与在服务器上使用它的速度相同,它通常看起来更快 - 在用户眼中更好。

Pros to Server Side 服务器端的优点

  1. You have more control on the back end data, easier to save information the user has, favorites, how many times they search, etc. 您可以更好地控制后端数据,更轻松地保存用户拥有的信息,收藏夹,搜索的次数等。
  2. Less worry about client computers. 减少客户端计算机的担心。 You never know when a client might have 32 tool bars installed which can cause errors with script's on pages. 您永远不知道客户端何时安装了32个工具栏,这可能会导致页面上的脚本出错。 Server side eliminates this. 服务器端消除了这一点
  3. C#. C#。 Plain and simple I love it better than JavaScript 简单而简单我比JavaScript更喜欢它

You might be able to squeek away with both by loading it server side, but updating client side. 您可以通过加载服务器端,但更新客户端来解决这两个问题。 call the same methods, but just do one on the first load, then use script for the rest. 调用相同的方法,但只需在第一次加载时执行一次,然后使用脚本进行其余操作。

Update: 更新:

For caching on twitter, I believe you can cache previous tweets so you don't need to fetch them again. 对于在twitter上缓存,我相信你可以缓存以前的推文,这样你就不需要再次获取它们了。 Should I output cache my control that looks up twitter RSS onload? 我应该输出缓存我的控件查找twitter RSS onload吗? has a topic on that. 有一个主题。

If you're not having live updates, then you could easily do that on the server side, or Jquery side. 如果您没有实时更新,那么您可以轻松地在服务器端或Jquery端执行此操作。 If you're looking for SOE, I would opt for server side on the initial load, as that is a point you did mention. 如果您正在寻找SOE,我会在初始加载时选择服务器端,因为这是您提到的一点。

I'd do this client-side. 我做这个客户端。 But if there is need for SEO, I'd also present cached version from server in a hidden div. 但如果需要SEO,我还会在隐藏的div中提供服务器的缓存版本。 That is, webserver would have tweet cache of some sort. 也就是说,webserver会有某种类型的推文缓存。

Do you want it to update automatically? 你想让它自动更新吗? (like a live feed) (比如直播)

I would load it server side then update it live with js if you want the live update part. 如果你想要实时更新部分,我会加载服务器端然后用js更新它。 If your doing SEO server side is the only way and if you want truly live for user experience. 如果你做SEO服务器端是唯一的方式,如果你想真正的用户体验生活。 js is the way. js就是这样。 You CAN have both. 你可以两个都有。

我也在我的网站上做了这个,我编写了自己的推特工具,你需要在服务器端做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM