带 www 或不带 www 的默认 URL 有何优缺点?

发布于 2024-09-13 01:17:24 字数 243 浏览 2 评论 0原文

我们需要将默认 URL 设置为唯一名称。如果是 www 则没有前缀,反之亦然。因此要做出的决定是坚持使用 www 或不使用前缀。

没有为所有子域设置前缀 cookie。它还有什么其他缺点?或者好处?

基本上我们需要 OpenID 这个,因为如果用户来自 www 或没有前缀,OpenID 会让他们看起来不同。

由于我们的网站是新的,因此我们可以选择其中之一。此外,域名的外观也不是很重要。

We need to default URL to unique name. If it is www then with no prefix or vice versa. So decision to be made is either stick with www or with no prefix.

With no prefix cookie is set for all sub domains. What are other downsides for it? Or benefits?

Basically we need this for OpenID as OpenID will make users look different if they came from www or with no prefix.

As our site is new so we can go with either one. Also, how the domain name looks is not much of a concern.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何处潇湘 2024-09-20 01:17:24

无论如何,您可能希望将一个重定向(使用 HTTP 301 - 永久重定向)到另一个,因为这样维护一致的 URL 会容易得多。因此,无论您决定做什么,只需确保实际身份验证是在重定向之后完成的,并且看起来不同的用户不会成为问题。

也就是说,您是否想要 www 完全取决于应用程序中其他内容的工作方式。您提到将为所有子域保存domain.com的cookie - 这是您想要的吗?您是否需要进行区分(例如,允许用户为子域设置自己的身份验证系统,就像共享托管服务可能做的那样)?

如果您发现包含和排除 www 之间的差异对您的应用程序没有影响,那么我会选择使用 www。造成这种情况的主要原因是我对互联网当前趋势的了解 - 越来越多的应用程序(SO 就是一个例子)倾向于忽略 www ,无论是链接到自己的网站时,还是在不同类型的营销中。

然而,要点是让两者都工作。您希望您的网站因用户没有在网址开头输入www而中断。

You probably want to redirect (with a HTTP 301 - Permanent Redirect) one to the other anyway, since maintaining consistent urls is much easier that way. So whichever you decide, just make sure the actual authentication is done after the redirect, and users looking different won't be an issue.

That said, if you want www or not depends entirely on how other things in your appliction works. You mention that cookies for domain.com will be saved for all subdomains - is this something you want? Are you ever going to need to differentiate (for example, by allowing users to set up their own authentication systems for subdomains as a shared hosting service might do)?

If none of the differences you find between including and excluding www matter to your application, I'd go for not using www. The main reason for this is my picture of current trends on the internet - more and more applications (SO is an example of this) tend to leave the www out, both when linking to their own sites, and in marketing of different kinds.

However, the main point is make both work. You don't want your site to break because the user did(n't) type www at the beginning of the url.

一身软味 2024-09-20 01:17:24

如果使用www子域,您在交付静态内容时可能会受到性能影响,如下所示:http://developer.yahoo.com/performance/rules.html#cookie_free。据我了解,如果您使用 http://example.com/http://static.example.com 作为静态内容,您在主域将随请求一起传递到您的静态子域。

通过为静态内容购买不同的域,可以很容易地避免这种情况。但是,这当然可以通过使用 www 子域来解决。

话又说回来,这是一个非常小的骗局,只有当您处理高需求的网站时才会真正发挥作用。 (例如,Digg 使用 http://digg.comhttp://*.diggstatic.com)。

最后,我想说,这是一个小问题,如果性能开始受到影响,它可能可以得到解决。不要过早优化,等等......

并且,正如 @Tomas Lycken 指出的那样,即使您不使用子域,也要确保您考虑了 www

By not using the www subdomain, you can suffer a performance hit when delivering static content, as noted here: http://developer.yahoo.com/performance/rules.html#cookie_free. As I understand it, if you use http://example.com/ and http://static.example.com for static content, any cookies you set on the main domain will be passed with requests to your static subdomain.

This can be avoided quite easily, by buying a distinct domain for static content. However, this can certainly be dealt with by using a www subdomain.

Then again, this is a very minor con, and really only comes into play when you're dealing with a high-demand site. (For example, Digg uses http://digg.com and http://*.diggstatic.com).

Ultimately, I would say that this is such a minor problem that it can probably be dealt with if performance starts to suffer. Don't optimize prematurely, and all that...

And, as @Tomas Lycken points out, make sure you account for www even if you don't use the subdomain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文