gpt4 book ai didi

http - 当一个主题被删除时,我应该为公告板系统使用 404 Not found 还是 410 Gone?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:27:02 25 4
gpt4 key购买 nike

我正在创建一个公告板系统,现在我正在为管理员实现一个“删除主题”功能。如果有人打开已删除的主题,服务器找不到它,那么它一定是 404。另一方面,该主题已经存在一段时间,所以我必须使用 410。实现 410 需要一个名为 deleted_topics 的新表,因此将需要更多空间。但是,我认为 410 更适合搜索引擎。你怎么看?我应该使用 404 还是 410?

404 未找到

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

410 走了

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer working at the server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner.

谢谢,

最佳答案

显示 410 比显示 404 需要更多的努力,因为要知道它是 410,您至少需要在数据库中维护前一个页面的“幽灵”。如果这对您来说不是问题,我会认为 410“更好”和“更友好”,因为它提供了更多信息。如果您不想为在数据库中维护墓地而烦恼,那么 404 当然也是可以接受的。

我不喜欢 Alohci 重定向到不同页面的方法。最终结果看起来用户无意中进入了“输入新主题”页面(或其他)。这可行,但我认为更好的解决方案是创建一个自定义 410 页面(或 404 页面,如果您不想支持 410),其中包含手头案例的特定信息。 IE。你的 410 不应该只说“消失”,它应该说“这个帖子已被删除,这里是类似帖子的链接或创建新帖子的链接”。您的“404”不会提供那么多的可用信息,但它仍然可以提供此类信息和链接的一部分。

我想“自定义 410 页面”在外观上与“使用 301 重定向”很接近,但一个重要的区别是您网站的机器人用户(其中​​有很多!)更准确的状态,并知道从他们的抓取索引中清除旧链接——这最终会为他们和你节省一些不必要的流量。

关于http - 当一个主题被删除时,我应该为公告板系统使用 404 Not found 还是 410 Gone?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1855046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com