I have a controller action that dynamically renders a graphic, given several input parameters. Since it is slightly noticeable when the graphic renders, I use the Output Cache to avoid re-rendering.
There are several dozen input parameter combinations that are used very frequently. I thought it would be a good idea to warm the cache so that the first visitor to use a given one of those combinations does not experience a delay.
To that end, I directly call the controller from Application_Start() like this:
UtilController uc = new UtilController();
uc.GenerateImage(p1, p2, p3);
By setting a breakpoint, I see that the controller action is called and the image is generated. However, the first (and only first) time that image is requested by the browser, it is generated again. For purposes of this test, the browser is configured not to cache anything, and I carefully compared the parameters used to call the controller action.
Is the Output Cache not invoked when the controller action is called directly? Is there a better method (hopefully one self-contained to the web project) of pre-warming the cache?