Welcome Guest, Not a member yet? Register   Sign In
Yet another cache question
#1

[eluser]SpooF[/eluser]
Does the cache function cache on a per controller basis? Basicly if I have pagination in one of my controllers, will it cache the first page and when someone requests the second page what will happen? Will it display the cached page or is it smart enough to work around the pagination?

Okay, so instead of waiting for someone else to test this out, I just did and without looking at the caching code, it looks like CodeIgniter takes into account the URL. So it cache each page of the pagination. Its late Undecided

Dont know why I asked, could of easly thrown it in and see what happened. Maybe I just like to "hear you guys talk" ;-P


However, because its late and I'm to tired to look into the code, has anyone build an exertion to the caching library to delete a cached file? Say I want to cache a file for 60 minutes, but if it updated I want to delete the cached file.

Cancel that, the cache file name is a mp5 of the URL, so all I have to do is store the REQUEST_URI in a flash session variable and when someone edits/alters the page I simple just delete that file.

I figured I would post this anyways in hope that someone else will find it handy.
#2

[eluser]SpooF[/eluser]
Heres the code I'm using:

This is the referring URI:
Code:
$this->session->set_flashdata('last_uri', $this->uri->uri_string());
This should go at the end of your function, as this is truly the URI of the current page request.

Code:
$path = $this->config->item('cache_path');
$cache_path = ($path == '') ? BASEPATH.'cache/' : $path;
$uri =    $this->config->item('base_url').
          $this->config->item('index_page').
          $this->session->flashdata('last_uri');
                
$file = $cache_path.md5($uri);

if(file_exists($file))
{
    unlink($file)
}
The above code will delete the cached file for the previous page.

I'm using this setup for when someone posts a comment to one of my posts.




Theme © iAndrew 2016 - Forum software by © MyBB