What is the best practice for getting entities from an array of ids?
I've tried a query using Entity.ID.Includes, and that works for the first query but the second time (sending different ids) you get the same result since the query is cached.
The only way I've found is looping through the ids and using for example ImageGalleryHandler.GetImage()
I'd say that it depends on context. If the entities are likely to already be in the cache or likely to be fetched again by ID from the cache I would loop through the array and fetch each by ID. If however the array is very big and the entities aren't likely to already be in the cache I would use the query system. I'm not sure why you are experiencing that caching problem though. The cache key should be built up by the parameters in the query so that if atleast one ID differs the second query should have another cachke key. Hopefully someone else will be able to answer that. You could also post your query here and I'll gladly take a look at it.
Another alternative could be to use the QueryHandler to get the query result as it has a GetQueryResult method that has an overload which lets you tell it not to cache the result. Then you can, should you need to, cache the result your self.