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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vishal

    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.....

  • Erwin Moller

    #2
    Re: make html page and store on harddrive from database for pagination technigue

    vishal wrote:

    Hi Vishal,
    [color=blue]
    > 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.[/color]

    This clearly needs optimalisation. :-)
    [color=blue]
    >
    > 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?????[/color]

    I am sure there is some chachingmechani sm 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.

    [color=blue]
    >
    > thxs for your reply in advance.....[/color]

    Succes.
    Regards,
    Erwin Moller

    Comment

    • micha

      #3
      Re: make html page and store on harddrive from database for pagination technigue

      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_n ews_page.php - generates static news page

      ..htaccess - points the errorhandler for 404 to
      generate_html_n ews_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_n ews_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

      Comment

      • Chung Leong

        #4
        Re: make html page and store on harddrive from database for pagination technigue

        Google "apache rewrite caching."

        Comment

        Working...