WEB Problem with my caching system

Discussion in 'OT Technology' started by Style, Jul 19, 2008.

  1. Style

    Style Boioioioioioioioing

    Joined:
    Apr 29, 2005
    Messages:
    13,778
    Likes Received:
    0
    Location:
    Dubai
    I found a caching code on the net (can't remember where), and I'm having a little problem with it.

    It's working really good (maybe waay too good), that when I update the page and up it to the server, and want to see the changes in the browser, well the caching script kicks in and I can't view the new updates, but only the cached page. I tried refreshing the page, hard refresh (ctrl-F5), clearing the cache in my browser, restarting the browser... Still the old page is shown. :wtc:

    So the question is, what the hell is wrong with this script? Here it is:

    At the very beginning of the page, before the doctype, I have this:

    Code:
    <?php
    
        $cachetime = 3600;
    
        if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) > (time()-3600))){
    
            // Client's cache IS current, so we just respond '304 Not Modified'.
            header('Last-Modified: '.gmdate('D, d M Y H:i:s', (strtotime($headers['If-Modified-Since']))).' GMT', true, 304);
            exit();
        }  
    
        header('Last-Modified: '.gmdate('D, d M Y H:i:s', (time()-$cachetime)).' GMT', true, 200);
        ob_start();
    
    ?>
    At the very end of the page, after the </html> tag, I have this:

    Code:
    <?php 
    
    SendLength(); 
    
    function SendLength(){
    
        if(ob_get_length()){
            header("Content-Length: ".ob_get_length());  
            ob_end_flush();  
            die;  
        }
    } 
    
    ?> 
    So what's the deal with this?
     
  2. auveeb

    auveeb DATS CUTE

    Joined:
    Mar 22, 2005
    Messages:
    11,467
    Likes Received:
    0
    Location:
    New York City, NY
    That's what a cache script does to my knowledge :dunno:
     
  3. 197666

    197666 New Member

    Joined:
    Jun 21, 2008
    Messages:
    197
    Likes Received:
    0
    .

    If you're using WP, use the WP-super cache plug.
     

Share This Page