CodeIgniter Forums
Help with ['cache_on'] = TRUE - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Help with ['cache_on'] = TRUE (/showthread.php?tid=58045)



Help with ['cache_on'] = TRUE - El Forum - 05-08-2013

[eluser]Unknown[/eluser]
Hi Guys, first I apologies I am not a coder in any way, I have a rudimentary knowledge of PHP where i can read and edit basic functions. That said I inherited a Codeigniter application which is basically an entry form. The problem is when we got a lot of traffic to the form it caused a high load on the server and the host suspended the script.

So my question is, will turning on database caching help with the server load, and will it cause issues with the application when each user is submitting new data to the database?

I have tested it on a localhost and it seems working fine with no issues, but I'd like some advise before I do it on the live site.

Thanks


Help with ['cache_on'] = TRUE - El Forum - 05-09-2013

[eluser]Alucemet[/eluser]
When you use database caching, the query is cached, so you don't want to use it if the data might change. The reason why is that the query is no longer done, but instead the data comes from a file that is written to disc. You could do something where you delete the cache file every X minutes. This is done by high traffic websites so that changes don't appear immediately, but refresh every few minutes.


Help with ['cache_on'] = TRUE - El Forum - 05-10-2013

[eluser]jairoh_[/eluser]
[qoute]
Only read-type (SELECT) queries can be cached, since these are the only type of queries that produce a result. Write-type (INSERT, UPDATE, etc.) queries, since they don't generate a result, will not be cached by the system

Getting a performance gain as a result of caching depends on many factors. If you have a highly optimized database under very little load, you probably won't see a performance boost. If your database is under heavy use you probably will see an improved response, assuming your file-system is not overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database operation to a file-system one.

In some clustered server environments, for example, caching may be detrimental since file-system operations are so intense. On single servers in shared environments, caching will probably be beneficial. Unfortunately there is no single answer to the question of whether you should cache your database. It really depends on your situation.
[/qoute]

i haven't tried this one, looking forward to the replies of the community here.