php to cache search content.

Discussion in 'PHP' started by login, Mar 30, 2007.

  1. #1
    I use a method with php and .htaccess to cache search results.
    The two files are begin_caching.php and end_caching.php
    In the begin_caching.php there is written
    "$cachetime = 8000000; // Seconds to cache files for"

    At the time of caching I thought that 8000000 would be long enough time to cache the content. However I do regret that now and want it to be cached forever. Is it enough to change the time here or do I have to cache all pages again changing the cache time ?

    As you understand I do not understand this system so it may be a stupid question to you.:D
     
    login, Mar 30, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Lil more details about your methods, maybe some code and a reason for you wanting to cache all search results, I'm a little confused as to why you might want to do this.
     
    krakjoe, Mar 30, 2007 IP
  3. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Here is the method, it works very well.
    http://www.ilovejackdaniels.com/php/caching-output-in-php/

    What part or where is deciding and telling when to delete the cached files ? What should I change to make the already cached files not getting deleted ?

    The reason I am caching is to speed up the loading of pages. My server is not to fast.
     
    login, Mar 30, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    
    if (time() - $cachetime < $cachefile_created ) {
    //ob_start('ob_gzhandler');
    @readfile($cachefile);
    //ob_end_flush();
    exit();
    }
    
    PHP:
    if ( true ) would be the quickest way of going around it without changing too much I think.....
     
    krakjoe, Mar 30, 2007 IP
  5. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Thanks krakjoe, but I don`t know php at all. Just managed to install this with a step by step instruction :eek:

    So it looks like this now:

    if (time() - $cachetime < $cachefile_created ) {
    //ob_start('ob_gzhandler');
    @readfile($cachefile);
    //ob_end_flush();
    exit();
    }

    How should it look like if i don`t want the cache to expire ?
     
    login, Mar 30, 2007 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    if ( true ) {
    //ob_start('ob_gzhandler');
    @readfile($cachefile);
    //ob_end_flush();
    exit();
    }
     
    krakjoe, Mar 30, 2007 IP
    login likes this.
  7. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #7
    great, thanks a lot. greeeeeeeeeeeeeen :)
     
    login, Mar 30, 2007 IP