SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict agentforte's Avatar
    Join Date
    May 2007
    Location
    Toronto, ON, Canada
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Caching profiles, displaying randomly

    I am trying to figure out a way to display profiles on my site randomly and using cache techniques to make it faster.

    I am hoping that someone can explain how caching works and if the idea I have would work.

    Instead of caching a page with 5 user profiles on it, can I cache the user profiles seperately and have the page include random profiles?

    I was thinking about saving the summarized user profiles that are found often seperately as text or html files and "including" them when a search turns up their profile (rather than generating it on the fly), and only updating them when the user updates their profile. When someone does a search, the profiles would be assembled randomly onto the page.

    IF there are any good tutorials or articles online that explain how to cache, please include them.
    Last edited by agentforte; Aug 20, 2007 at 13:42.

  2. #2
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First you need to find out what is causing the slow down of your pages.

    If you are using DB , check if queries are taking long time. And if they are then look into them and see if you can optimize them (usually by adding indexes)

    You could also use MEMCACHE to cache the results of your queries too.

    If your DB is fine , and problem is in php rendering HTML , you can use prebuilt caching classes or SMARTY (comes with caching mechanism).

    Or if you want to do it your self , look into Output Control functions
    http://www.php.net/manual/en/ref.outcontrol.php

    Which would allow you to store html results to a variable and then save it to a file all rendered. So on next call you can just use the rendered page.
    IQStaffing - IT Recruiter
    - Need an IT job? let us find you one!
    http://www.iqstaffing.com

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could do something like this:

    PHP Code:
    if (cacheExists && notExpired){
      
    // grab and echo cache
    } else {
      
    // regenerate cache file
      // store cache file


  4. #4
    SitePoint Addict agentforte's Avatar
    Join Date
    May 2007
    Location
    Toronto, ON, Canada
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if I have this right...

    is it possible (an beneficial) to update cache files.. or should they just be replaced?

    Thanks for your input XtrEM3 and iqstaffing. I will try out your methods.

  5. #5
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In 99% cases it is faster and easier just to replace them.
    IQStaffing - IT Recruiter
    - Need an IT job? let us find you one!
    http://www.iqstaffing.com


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
  •