ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

manual clear page caching code

August 19, 2009 1:27pm

Subscribe [3]
  • #1 / Aug 19, 2009 1:27pm

    ifew

    11 posts

    i’m create some easy method for clear page caching by extend from CI_Output


    1. create file in System/Application/Library

      /system/application/libraries/My_Output.php (“My_” is your library suffix name)

    2. extend from CI_Output

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
        /**
        * Clear Cache
        *
        * Responsible for sending final output to browser
        *
        * @package        CodeIgniter
        * @subpackage    Libraries
        * @added-by    Chitpong Wuttanan (<a href="http://lab.tosdn.com">http://lab.tosdn.com</a>)
        */
        class My_Output extends CI_Output {
    
            function clear_cache($set_uri = NULL){
                $CFG =& load_class('Config');
                $filepath = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path').md5($set_uri);
    
                if(file_exists($filepath)) {
                    @unlink($filepath);
                    log_message('debug', "Cache deleted for: ".$set_uri);
                } else {
                    return FALSE;
                }
            }
        }
    
        ?>

    3. how to use page caching

    $this->output->cache(60); //1 Hour
    $this->load->view('profile.php');

    4. how to clear page caching

    $this->output->clear_cache('http://www.web.com/profile');
    // "http://www.web.com/profile" is URI page for clearing

    Reference Page Caching with CodeIgniter and Cache Clearing code

  • #2 / Aug 19, 2009 4:26pm

    DominixZ

    23 posts

    I suggest another good function. It is clear_all_cache();

    This may be nice when use in backend.

  • #3 / Aug 20, 2009 4:34am

    ifew

    11 posts

    this function good for clear some page :D

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases