CodeIgniter Forums
caching - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived General Discussion (
+--- Thread: caching (/thread-57127.html)

caching - El Forum - 02-18-2013

I just completed the basic tutorial.

I then edited views/pages/home.php

but on going to that page it displays the old page. If I refresh it shows my edits. I've tried this from different browsers... so it seems the caching is on the server.

There are no extra files in application/cache so I'm not clear how caching works with Codeigniter.

During development how do you disable caching as pages will be changing all the time..


caching - El Forum - 02-18-2013


Its unlikely that Codeigniter is caching the page, to enable caching you need to use $this->output->cache(n); and if a page is cached it will be stored in the cache folder but you say it is empty.

caching - El Forum - 02-19-2013

Ok, that's what I thought. I just checked and it seems okay now. Maybe a glitch in my browsers.

thanks for clarifying!

caching - El Forum - 02-20-2013

>> During development how do you disable caching as pages will be changing all the time..

In my base "index.php" file I define environment variables depending on which server I am on (I have 3, local, testing, live).
When I'm on my local or testing testing server I define another constant called "testing_cache" and set it to 10 (which is 10 seconds).

Then when I'm setting my "cache_age" I set it like this ....(testing_cache?testing_cache:"360")
Where 360 is the age I want to set my "live" cache to. In local and test server testing_cache exists, so it gets set to 10 seconds, else it gets set to whatever I defined (360 in this example)

This allows me to test/debug cache stuff in local and test environments (ie, putting an echo statement if running from cache or not, etc). I run the page that "should" set the cache, and if I refresh in 10 seconds I should see my "echo cache file found" statement. This allows for the cache to be destroyed after a tiny 10 seconds, a good enough time limit for me for debugging without manually deleting caches after creating them and not too long to wait for it to be destroyed.

I use a very similar pattern for email addresses. In local and test I define a constant called "testing_email" and set it to my "test" email address. When sending out emails to users (ie, someone replied to a forum post of theirs, sending account activation emails, etc), in my test and local servers they get sent to my test email address, else on live server they get sent to the correct email address. I like to back propagate live DB data into my test DB as it give a more realistic "test" experience, db query speed testing, etc (better to have your test db with 100,000 real entries than 12 test entries), but my users certainly wouldn't be happy if they started receiving emails to their live addresses while I was testing!!!

Hope that helps.