SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right now, my front page is a script that pulls news out of MySQL and display on the fly, so everytime someone goes to the front page, MySQL is called.

    But what if set it so when I submit news to MySQL, it creates a text/php/XML file as well, and my news page grabs news out of the txt/php/XML file instead of MySQL, that way there won't be as many calls to the db.

    Would that work, and are there any problems to this solution?

  2. #2
    SitePoint Addict kunal's Avatar
    Join Date
    Oct 2000
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it would work.. yes.. but it would defeat the purpose of using mysql at all... the point of using mysql is to increase speed and reduce server load... plus, the script you are using, virtually wont have any load on the processor coz its just one select statement.....
    i dunno...

  3. #3
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not necessarily true. What you're talking about is a simple caching system. You have a text file with all of the news HTML in it sitting somewhere on your server, which is then included into your front page. Instead of dynamically generating the whole page from the database every time someone accesses the page, you only generate the cached text file when you've changed the database. This would dramatically decrease server load, especially on a busy site. This is definitely a good thing

    While ideal for the purpose you are describing, this method has it's drawbacks for more complicated pages. For example, if you had a comments system and each news story displayed the number of comments for that story next to the headline - you would now have to either ditch the cache completely or re-generate it whenever a new comment is added.

    For a simple news front page the system you describe is ideal. I think slashdot use a very frequently updated cache for their front page (despite the comment counters), and systems like Newspro (where the news is stored in a flat file) rely on caching the HTML used to display the news page as well.

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With little calculation or data manipulation required, text files (caching) work best.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you are describing is quite a good idea for busy web sites and I do believe that SitePoint do something similar, they re-generate the front page of SitePoint.com every hour if I recal correctly.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  6. #6
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Back when I first started using Cold Fusion, I noticed that the smallest query would be using 100% of the resources on my site. So I designed my site to write HTML pages every 12 hours and now I use about 4% of the resources. You just have to figure out what do you really need that needs to be dynamic and what can be static and what could be changed. If you need a PHP script that can get and write file, lemme know. I got one that works for me. I had a lot of help from people on this site in getting it to work.
    <///////~

    www.sohh.com

  7. #7
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, just have a look at the end of Kevin's Tutorial, " Semi-Dynamic Pages" ,you will find it here:
    http://www.webmasterbase.com/article.php/228/1164
    It's doing exactly what you want, getting the information out of your MySQL Database and writing a "non-dynamic" file of it.
    You can use a cron-job for it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •