tags:

views:

243

answers:

2

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.

+1  A: 

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.

LBushkin
A: 

check this article...this will cache images, but u can cache every kind of file in the same way....

http://www.codeproject.com/KB/aspnet/CachingImagesInASPNET.aspx
Muhammad Akhtar
A very interesting article which shows the potential power of resource handlers but I'm struck by this statement she makes "There are two different ways to avoid this problem. On the one hand you can tell IIS to cache images on the client, and on the other hand you can do this directly in ASP.net (which is a bit more complicated)." So if you adhere to the KISS principle why would you attempt do this?I'm trying to work out if caching resource files and their resources is better than just accessing them as resources. As @LBushkin points out the only way I'll know is to profile the code.
Dave Anderson