Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to cache and haven't used it on my projects. I would like to know about what is best practice in caching.

Should caching be done while developing or finish development then cache everything?

share|improve this question

closed as not a real question by gnat, Jan Hudec, Walter, Robert Harvey, thorsten müller Nov 29 '12 at 11:25

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Cache what exactly? – Simon Whitehead Nov 28 '12 at 11:54

In this case, caching is an example of premature optimization. So that would imply it's a bad idea.

You don't know where your performance bottlenecks will be yet, so applying caching now would be a mistake.

Get the application working first, run some performance analysis, and then start using caching were appropriate.

So that means to get the development mostly done, and as part of your refactoring / refinement work you'll identify where the performance issues are.

share|improve this answer
Ok I'll try that. – fujisan Nov 29 '12 at 2:03

You should build in the Caching of data whenever it logically comes up in development, but its true that you don't want to be sitting around waiting for the Cache to expire while you are doing dev.

One solution would be to set the Cache duration in a configuration setting (xml, etc), and once you are satisfied that it works with whatever production setting you will likely use (10min, 1 hour, 1 day, whatever), turn it down to something like 1 second in the config, so that you can continue with dev. That way, changing the Cache expiration back up to the 'real' value won't involve a code change.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.