We are using Sitecore 8 in our project, which has two different sites.
When trying to retrieve the home item for one of these sites, it seems to be unreliable:
var database = Factory.GetDatabase("Web");
var homeItem = database.GetItem(new ID("{FAF3904C-4BE4-ED80-891A-DFEE0A4C18C5}"));
When the site has just been restarted in IIS, or when the Sitecore cache has been emptied, sometimes the homeItem variable is null.
It seems that the database object does provide items for one site (the "current" site, corresponding with our request URL) but it doesn't provide items for the other site.
On subsequent requests for the other site, it seems that items for both sites are available. And sometimes, even after restarting IIS or clearing the Sitecore cache, all items are readily available from the start. (I haven't found a number of steps which reproduces the problem consistently.)
I'm guessing that some kind of caching somewhere (probably outside the Sitecore cache) is happening, but I have no clue what exactly it might be.
Does anybody know why database.GetItem could return null sometimes for items that do exist, but might belong to a different site than the current one? And more important: how can I get items from the database with the guarantee that items from all sites are available?