1

I enabled query caching in CodeIgniter via the application/config/database.php file and it worked. I then disabled it, and commented out the folder path. When I then re-enabled caching and un-commented the folder path, caching would not work.

I have tried other directories. This is an issue on both local, and web servers.

$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = './application/cache/';

These is my database.php settings. I have tried removing the '.' from the beginning of the string. I have also tried removing the trailing and preceding slashes.

Any help would be much appreciated. Thank you.

Edit: I know the folder is writable as storing a full page cache works.

6
  • 1
    what exactly do you mean it does not work? any errors? have you tried to use an absolute path instead? clearing up the cache dir and trying again? perhaps enabling CI's logging could help here, too - just make sure the logs folder is writable Commented Nov 28, 2012 at 12:53
  • No errors whatsoever. I have tried an absolute path and still no dice. It's incredibly infuriating. I know the folder is writable as if I use $this->output->cache(100);, it writes to the folder. I emptied the cache directory too, and still nothing. Enabling logging produces no errors. Commented Nov 28, 2012 at 13:03
  • 1
    any chance you're using multiple database configurations - Environments or different DB groups (other than default) and one of them has the old setting? Commented Nov 28, 2012 at 13:06
  • I did, but I removed the second database configuration and it still doesn't work. I even replaced database.php just in case, and nothing. Commented Nov 28, 2012 at 13:11
  • well, then the only thing that comes to my mind it to simply try and create an empty CodeIgniter installation and use a sample DB code in the Welcome controller to see if that works at all. From that point, you should be able to tell the difference between your app and the default (for example by using comparison tool in Eclipse). Commented Nov 28, 2012 at 13:14

1 Answer 1

10

Define the caching directory in config/database.php as follows:

$db['default']['cachedir'] = APPPATH . 'cache';

Also, make sure you directory is writable (if you are on Mac or Linux)

sudo chmod 777 -R application/cache

If still doesn't work, try explicitly turning cache on before running db queries.

$this->db->cache_on();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.