Reputation: 21
I am not sure if I should cache an xml file that my application will be using. I don't know how frequently it will be reading from the xml file. Please advice. Thank You.
Upvotes: 1
Views: 129
Reputation: 14585
Depends. If memory isn't a concern but performance is, then read in the structure using XmlReader and store it. This way it won't need to be parsed again. If it's not going to be reader frequently then don't bother. Xml parsing isn't cheap. 600KB won't break the bank on memory but you'll have to deal with caching setup, but it will be worth the performance benefits especailly if you do any transforms on it or schema validation.
if this is website then store it as a static
public static XmlReader ...
That way it's shared across all sessions.
Upvotes: 2
Reputation: 17010
This is an "it depends" answer.
I don't think you gain much with a 600kb XML file with caching. It is rather small. Unless ... you hit the same data over and over again, in which case not caching may affect scalability.
The short answer: I don't know enough about your application to give you a single answer.
Upvotes: 1