dra8603 2013-05-02 09:46
浏览 29

Codeigniter网页缓存

How can i cache a particular part of the web page, I know how CI caching mechanism works also i am aware of Partial Caching.

Assume that we have a page with some dynamic data associated with. If i used caching then i cannot get the actual data on page refresh.

How can i override this problem ?

I have one idea in my mind, While inserting the data just keep another field, lets say MD5_CONTENTS which will store the MD5 hash of the contents ( Normally form fields ). And next time on update i can compare the MD5 strings to determine changes. If changes are found then delete the cache file.

I dont know this is gonna work or not, But its littlebit hard for my current implementation.

What is the best method to achieve Partial Caching ?

Thanks

  • 写回答

1条回答 默认 最新

  • dongping4901 2014-02-13 11:02
    关注

    Would the caching driver do the trick?

    http://ellislab.com/codeigniter/user-guide/libraries/caching.html

    $this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
    
    if ( ! $foo = $this->cache->get('foo'))
    {
         echo 'Saving to the cache!<br />';
         $foo = 'foobarbaz!';
    
         // Save into the cache for 5 minutes
         $this->cache->save('foo', $foo, 300);
    }
    
    echo $foo; 
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常