标记页面...会话变量或许多静态页面?
我有一个网站,其中包含许多新闻文章。在数据库中,每篇文章都有所谓的“标签”,用户可以看到这些标签显示在文章旁边。当用户单击该标签时,他们将被定向到也包含该标签的其他文章的列表。
我应该为每个新创建的标签生成一个不同的 HTML 页面,还是应该创建一个页面并根据用户使用会话变量单击的标签来改变内容???
显然,这些页面不会完全静态,因为每次上传带有匹配标签的新文章时我都会更新它们
i have a website which contains many news articles. IN the database, each article has so-called "tags" which the user sees displayed alongside the article. When the user clicks on the tag, they are directed to a list of other articles also containing this tag.
Should I generate a distinct HTML page for each newly created tag, or should I create one single page and vary the content based on what tag the user clicked on using session variables????
obviously, the pages will not be completely static since I will update them everytime a new article with a matching tag is uploaded
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您当然不应该使用会话数据。这是针对需要持久化的数据,但它是根据每个用户设置的。将其用于每个请求数据只会破坏书签并引入竞争条件。
每个标签都应该有一个不同的 URI。 (从最终用户的角度来看)如果您使用动态生成的内容(通过查询字符串或解析服务器端代码中的 URI(大多数框架,例如 Dancer,将为您处理此问题))或者如果您使用生成的静态页面。
静态页面可以更轻松地处理缓存,并在流量非常大的系统上提供更好的性能,但如果内容发生更改,往往需要重建网站的大部分内容。您可以通过使用服务器端缓存(例如通过memcached)获得类似的性能改进。
动态页面通常更容易实现。
You certainly shouldn't use session data. That is for data that needs to persist, but it set on a per user basis. Using it for per-request data will just break bookmarking and introduce race conditions.
You should have a distinct URI for each tag. It doesn't matter (from an end user perspective) if you use dynamically generated content (either via a query string, or parsing the URI in your server side code (most frameworks, e.g. Dancer, will handle this for you)) or if you use generated static pages.
Static pages make it easier to handle caching and give better performance on very high traffic systems, but tend to require a rebuild of large sections of the site if content changes. You can get similar performance improvements by using server side caching (e.g. via memcached).
Dynamic pages are usually simpler to implement.
我建议您创建一个列表页面,其中包含所有包含特定标签(类似于 WordPress)的文章的标题和简短描述。
例如,以下是标签
jQuery
的列表页面:I suggest you to create a listing page that contains title and small description of all articles containing a particular tag similar to WordPress.
For example, here is listing page for the tag
jQuery
:我会创建一个页面,然后重写 url,以便它引用标签页面,这样
您就可以使用一个页面来更新内容,但允许每个页面都由 Google.com 编制索引。
我不确定你使用的是什么语言,但我会查找 URL 重写,
这里有一个在 apache 中重写的链接:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
这是在asp.net中重写的链接:
http://msdn.microsoft.com/en-us/library/ms972974.aspx
I would create one page, and then rewrite the url so that it referenced the tag page so something like this
this allows you to have one page to update the content with but allows each page to be indexed by Google.com.
I'm not sure what language you are using but I would look up URL rewriting
here's a link for rewriting in apache:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
here's a link for rewriting in asp.net:
http://msdn.microsoft.com/en-us/library/ms972974.aspx