最好的方式来管理,而不数据库动态内容 [英] Best way to manage dynamic content without databases

查看:169
本文介绍了最好的方式来管理,而不数据库动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计一个Web应用程序,它会做三件事情:

I am designing a web application which will be doing three things:

1)存储一些数据

2)使用户可用来查看这些数据

2) make user available to view these data

3)不时添加/删除/修改一些数据。

3) from time to time add/remove/change some data

看起来pretty的简单,但我想避免MySQL和PHP来minimase服务器资源的使用。我的主要目标是提供HTML文件的用户 - posts1.html(posts2.html,posts3.html ...(其中1,2,3是数据页)编号)

Looks pretty simple, but I would like to minimase usage of server resources by avoiding MySQL and PHP. My main goal is to deliver HTML file for user - posts1.html (posts2.html, posts3.html... (where 1,2,3 are numbers of pages of data)).

通常情况下,我会创造posts.php文件,它会发送查询到数据库中,但我的数据只更改了一天三五次,所以这将是一个巨大的浪费。

Normally, I would create posts.php file, which would send query to database, but my data are changing only three-five times a day, so it would be a huge waste.

相反,我想到了缓存这些数据,你会做足了大量的服务器资源,但在这种情况下,会有一些PHP code参与。

Instead, I thought about caching these data, what would spare a lot of server resources, but in this situation there would be some of PHP code involved.

我的另一个想法是建立在数据库中的每个变化之后,将要创建的所有HTML文件脚本,然后用它们替换旧的。但是,如果有人要求将取代现在的网页?这可能会导致错误,用户可以得到未完成的文件等。

My another idea is to create script that would be creating all HTML files after every change in database and then replace the old ones with them. But what if someone requests page that is replacing right now? It may cause errors, user can get the uncompleted file etc.

不过,有一个解决方案 - 我可以存储在两个目录创建的HTML文件(A和B),并使用的.htaccess做这样的事情(伪code):

However, there is one solution - I could store created HTML files in two directories (A and B) and using .htaccess do something like this (pseudocode):

if ( (HOURS)%2 == 0 )
   /postsX.html -> /A/postsX.html
else
   /postsX.html -> /B/postsX.html

这会给我足够的时间来升级所有文件。

It would give me enough time to upgrade all files.

我很想听听你怎么看待这件事和你会怎么做?

I would love to hear what do you think about it and what would you do?

推荐答案

如果你不想使用一个完全成熟的MySQL服务器时,使用的 SQLite的。这是PHP的一部分,非常轻巧。然后添加缓存在适当情况下。你的其他方法听起来像是在浪费时间给我。太多的精力太少增益。 SQLite的和缓存是经得起考验的。

If you dont want to use a full blown MySQL server, use SQLite. It's part of PHP and very lightweight. Then add caching where appropriate. Your other approaches sound like a waste of time to me. Too much effort for too little gain. SQLite and caching is tried and tested.

此外,你不应该担心资源浪费,除非你是在其上运行的短。您的应用程序犯规听起来它需要在这一点上进行缩放。因此,建立,将工作的最简单的事情。

Besides, you should not worry about waste of resources unless you are running short on them. Your application doesnt sound like it needs scaling at this point. So build the simplest thing that will work.

如果你必须有一个静态页面的方式,然后把所有这些文件到一个符号链接文件夹中。创建生成静态页面到一个新的文件夹(或者通过cron或手动触发),然后更改从旧文件夹中的符号链接到新文件夹的脚本。这样,您就不必担心人们点击你的网站,而其发电量。

If you have to have that static pages approach, then put all those files into a symlinked folder. Create a script that generates the static pages into a new folder (either via cron or manual trigger) and then changes the symlink from the old folder to the new folder. This way you don't have to worry about people hitting your site while its generating content.

这篇关于最好的方式来管理,而不数据库动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆