Hello Sitecore Family,
Recently, we were doing a POC of upgrading a Sitecore solution from Sitecore 7.0 to Sitecore 8.0 and while moving there (as in, not InPlace upgrade but by Migrating to new instance), we were doing a number of foundational tasks – like, upgrading the .Net framework to 4.5, upgrading ASP.NET version to 5.1, upgrading Glass Mapper to 184.108.40.206 and some others.
Now this solution we have is a multisite Sitecore solution and after upgrading a pretty basic website project with the above mentioned assemblies, we found that a couple of locations were showing images from some other site! weird.
We later found, that whichever site was loaded first, that image got loaded and that image was shown on other sites of the similar structure.
CACHING ISSUE! — Oh yes!
Oh but it was a simple Glass Mapper Html Helper, how can it lead us to caching issue?
@Html.Raw(GlassHtml.RenderImage(Model, x => Model.Logo, null, true))
Firstly, thanks to Mike Edwards for being approachable on Slack chat and giving a solution to the problem that we had. Glass Mapper is really well documented, and that’s where the solution was:
Quoting Mike Edwards here:
If you have written your lambda expression with reference to the Model as you have in your example you will need to turn off the lambda cache.
That’s what we did and bingo, the error was solved!
What we did?
We added the following code in the method called CreateResolver in the class GlassMapperScCustom in App_Start folder:
config.UseGlassHtmlLambdaCache = false;
A small suggestion Mike, documentation is great but search is good to have on Glass Mapper site. 🙂
Happy Solving Caching Issues! 🙂