1. Is there any criteria when to use caching like say use
caching if there are 5 cfincludes or custom tags in your code. Or
something like use caching if code has more than 10 cfifs. I didn't
find any article about it. or if .cfm file size is greater than say
Data on my website is static for hour or so & good
candidate for caching but I don't want to make code complecated if
new developer comes & caching is not improving performance
2. Also web page caching vs database query caching advantages
of one method over other.
The reason why there are not articles on this is that it is
massively subjective. It is based on load and where the bottle
necks are and how much dynamism is required.
For example if your home page looks the same regardless of
whether you are logged in or from a different location, etc. then
you could cache it as HTML on a schedule and that will remove the
need for ColdFusion to get involved at all for that page. However
if this is not the case and you have lots of dynamic elements then
you must look into alternatives, caching queries in variables gives
you the most control, I personally do not like query caching
handled by CF, but caching things in variables adds more management
code. Here we have developed a Java library that can cache objects
based on popularity and a timeout.
As you can see it is entirely subjective and really is based
on your current bottlenecks vs flexibility of your application.