473,379 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

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
3 1838
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
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
Google "apache rewrite caching."

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: BCS | last post by:
I have a web site in which the site administrator can input information to a database through a web form. The information then gets displayed on ASP pages. One field is a large text field. Of...
2
by: Andy Glew | last post by:
I have long looked for (and occasionally posted questions to groups such as this about) a tool that can take a group of HTML pages (nowadays XHTML, or XML) and produce a nicely formatted...
1
by: Henrik | last post by:
Hello all. I'm after some sort of pagination function. One that takes some in data that I provide, and returns an array of controls, pointing to page 2, page 3 etc. Trying to mimic the way that...
3
by: sean | last post by:
I have a table with fixed row of records SORTED by DATE using ADO pagination method. The user can click a link in one table cell and go to another page to modify the record. Once the updated record...
4
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
0
by: jhondcode | last post by:
Hi I want to make pagination in the jsp page but in the pagination the whole page is loaded . So i want to load only new table of record while click on the new page number in the page while other...
2
by: Roshawn | last post by:
Hi, On my asp.net page I have an html form. I've set runat attribute to server and filled it with server controls. All settings are as I like them. So here's the problem: when I perform a...
2
by: =?Utf-8?B?TWFoYXZpciBTaGFo?= | last post by:
hi, in c# asp.net gridview when we see page running, and check it's source. you can see that it has something like this at gridview table </tr><tr> <td>22/06/2007</td><td>45000</td>...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.