minimizing executed queries

Discussion in 'PHP' started by fatabbot, Aug 27, 2006.

  1. #1
    Hi,

    I have a file incl_leftmenu.php which i include on every page. It's the same on each page. But the query results in that file do not change very often. The problem is that each time a new page is loaded, all queries in incl_leftmenu.php are executed, which i think slows down load time alot. Are there any solutions for this ? Like re-load the left menu only every 15 minutes or so ?


    Thank you


    Fat Abbot
     
    fatabbot, Aug 27, 2006 IP
  2. Litewebsite

    Litewebsite Guest

    Messages:
    26
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could use a cache mechanism like MMCache or APC to reduce server load.

    A really simple thing could be setting up a cron that executes incl_leftmenu every X minutes and store the output/result as plain html file and include that file instead (just an idea).
     
    Litewebsite, Aug 27, 2006 IP
  3. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #3
    OR save the data in the global $_SESSION var. If the $_SESSION doesn't exist load the data from the db, otherwise just pull it from the session.

    This is nice because each user will have a "fresh" copy of whats suppose to be their when they load the page, and they will hold onto that until the session expires or they close the browser window.

    Custom cash mechanism :)
     
    drewbe121212, Aug 27, 2006 IP