By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,670 Members | 1,462 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,670 IT Pros & Developers. It's quick & easy.

make html page and store on harddrive from database for pagination technigue

P: n/a
i am creating a news site. i am adding new news in database and it must
be visible to user at top. and then second latest news and so on.

i am displaying 15 news on each page and then put a link for next 15
news on page.

my site is accessed by millions of people everyday. so for each when he
want to see news he click on news link and in my php program query is
run in database. so my database access became very slow because if one
million people clicks on news link, the database will be accessed and
query will be run one million times.

so i want to fast the news access. i thought that i create html page on
harddrive when i add new news in database. so when user clicks on news
hyperlink it checks whether the html file displaying first 15 news
already exist. if yes then it display that html file and if not exist
then php script query database for first 15 latest news.

is there any other optimized way available to achieve this than the one
i planned?????

thxs for your reply in advance.....

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
vishal wrote:

Hi Vishal,
i am creating a news site. i am adding new news in database and it must
be visible to user at top. and then second latest news and so on.

i am displaying 15 news on each page and then put a link for next 15
news on page.

my site is accessed by millions of people everyday. so for each when he
want to see news he click on news link and in my php program query is
run in database. so my database access became very slow because if one
million people clicks on news link, the database will be accessed and
query will be run one million times.
This clearly needs optimalisation. :-)

so i want to fast the news access. i thought that i create html page on
harddrive when i add new news in database. so when user clicks on news
hyperlink it checks whether the html file displaying first 15 news
already exist. if yes then it display that html file and if not exist
then php script query database for first 15 latest news.

is there any other optimized way available to achieve this than the one
i planned?????
I am sure there is some chachingmechanism around, but you can also roll your
own.
I think your plan is sound, but switch the logic.
Why check that the HTMLpage exists?
Just make sure it is there.

What about this: When a new article/new item is added, or if you want to
modify anything in the order: generate the HTMLpage(s) that contains it
once, and store them in plain HTML on disk.

I mean: You don't have to check every time, only when new newsitems are
added, so that would be the logical moment to regenerate the pages.


thxs for your reply in advance.....


Succes.
Regards,
Erwin Moller
Jul 17 '05 #2

P: n/a
you could make use of error 404.

suppose your news dir contains

a page called news.html - static news page

a page called generate_html_news_page.php - generates static news page

..htaccess - points the errorhandler for 404 to
generate_html_news_page.php

whenever you add new news in your db, have your script unlink()
news.html. so the 1st user to access (the now nonexistent) news.html,
will simply cause an error 404 and therefor an execution of
generate_html_news_page.html - and your static news.html is there
again.

this can of course be expanded to handle a couple of static news pages
too

micha

Jul 17 '05 #3

P: n/a
Google "apache rewrite caching."

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.