Question

Would there be any point in adding resx files to a distributed cache? What is the overhead of accessing the resources that would be saved by either a) caching the resource file itself b) caching the individual resources in the file? One immediate drawback is that it would break the internationalisation capabilites that you get.

Was it helpful?

Solution

Before implementing something like a caching strategy for resources, you should first instrument and profile your code to determine if resource access is really a bottleneck.

Now assuming it is, a resource caching strategy may certainly be a reasonable optimization - however, a lot would depend on the exact implementation choice. It may very well be that most of the expense of using resource files comes down to parsing and interpreting the contents of the resource file ... especially since resx files are typically in XML. Furthermore, using an external, distributed cache may introduce new sources of latency and potential failure into your design.

If resource access performance is really an issue, and the resources you deal with are not very large, you may be better off caching them in-process within your application. Load them on demand and then hold on to them. You can even use weak-references to allow rarely used resources to be discarded and reloaded as needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top