I have a WCF service that caches certain data and uses it to respond to web requests. To handle this requirement, I made a Singleton service (using InstanceContextMode.Singleand ConcurrencyMode.Multiple(yes, this is threadafe)).
I tried to set the maximum service timeout using the following binding:
<binding name="WebHttpBinding" receiveTimeout="24.20:31:23.6470000">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" />
</security>
</binding>
My problem is that the service instance is dying at unpredictable intervals, which means that the first request of the web request will cause the cache to be restored (a very slow process).
Ideally, the cache will be rebuilt at a given time every day without the need for a web request. I can configure the application pool to be reused at the set time, but this still will not solve the problem that the service will not receive an instance before the first web request. I would prefer not to make a small scheduled script that sends a request to the service, as this is a kind of hacking.
Is there a better strategy for doing caching in a WCF service? What have others done? Is there any best practice?
MgSam source
share