生成“动态”静态版本的最佳方式 网站
我有一个动态网站,即大量数据是从数据库生成的,但数据库内容很少更改(大约每周 1-3 次)。 这些更改是手动且受控的。
我更喜欢使用静态页面,而不是动态网站的开销。 我正在争论什么是最好的解决方案:
curl/wget/spider
这个问题提到了它。 我看到的缺点可能是:
- 需要手动清理(链接、丢失图像等)
- 无法混合静态和动态页面
代理
我可以使用代理将静态页面缓存一定天数。 缺点:
- 难以管理每个页面的缓存,
- 每次手动更改后都需要清除缓存?
使用程序生成静态页面
我当前的选择:我使用perl程序从动态内容生成静态页面。 这不能很好地扩展,因为我必须对大量 HTML 进行硬编码,尤其是页面结构
还有其他方法吗? 你会/你更喜欢什么?
I have a website that is dynamic in the sense that a lot of data is generated from a database, but the contents of the database changes rarely (about 1-3 times a week). These changes are manual and controlled.
Instead of having the overhead of a dynamic website, I prefer to use a static pages. I'm debating what is the best solution:
curl/wget/spider
This question mentions it. The disadvantages I see might be:
- manual clean up needed (links, missing images, etc.)
- cannot mix static and dynamic pages
proxy
I could use a proxy to cache the static pages for a certain number of days. Disadvantages:
- hard to manage the cache of each page
- need to clear the cache after each manual change?
Use program to generate static pages
My current choice: I use perl programs to generate static pages from dynamic content. This doesn't scale very well as I have to hard code a lot of HTML, especially the page structure
Any other ways to do it? What would you/do you prefer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Memcache 基础全页缓存,过期时间较长。 标记扩展可以让您仅使选定的页面范围失效。
Memcache base full-page cache with long expire time. Tag extension could allow you to invalidate only selected range of pages.
您想要这样做的任何特定原因,而不是仅仅设置数据库缓存解决方案阻止查询实际上必须访问数据库?
是否可能取决于您站点上的动态数据量以及服务器中的可用内存量,但它不会出现您担心的任何问题。
Any particular reason you want to do it this way instead of just setting up a database caching solution to stop the queries from actually having to hit the database?
Whether it's possible or not depends on the amount of dynamic data that's on your site, and the amount of memory available in your server, but it wouldn't have any of the problems you're worried about.
我会像您现在所做的那样,使用脚本生成静态页面。 您可以使用模板系统来避免每次都编写新的 HTML。
I would do it the same way you're doing it right now, using a script to generate static pages. You can use a templating system to avoid having to write new HTML every time.
您还没有提到尽快向用户显示更改后的数据有多么重要。
我们已经成功地在我们的网站上使用代理缓存来处理获得大量点击的动态页面。 根据我们希望客户多久看到更新的数据,我们为每个类别保留不同的缓存期限。
You have not mentioned how important it is to show the changed data as soon as possible to your user.
We have used proxy cache successfully for our website to handle dynamic pages which gets lots of hits. Depending upon how soon we want the updated data to be seen by customer we kept different cache age for each categories.