We are using some (custom) caches that get cleared when data changes in Sitecore - it's written so that it only clears the cache when items from a certain template are published (we don't want this cache to be thrown away each time an editor publishes a small unrelated content change).

This works fine but.. the cache gets filled with data based upon an index query. So if the cache is cleared, and the index is not yet up-to-date before the first request that refills the cache, we are (might be) caching old data. So I started looking into events that we could use after index end.

I found an indexing:end event, but as far as I could see the arguments are .. well, just the index name.

So my question is: is there a way to get a list of indexed items? (project is now on Sitecore 8.1 - but a solution on a higher version could also help)

2 Answers 2


When an item is updated in the index, the indexing:updateditem event is raised with the index name and item ID as parameters. You could add a handler for this event and either clear the cache based on that item, or append to a queue that you then process and clear when the indexing:end event is fired.

There is also indexing:deleteitem and indexing:added for deletes / adds.

  • Going to try this approach - seems like a good idea if I can get out of the events fast (as Richard mentioned).
    – Gatogordo
    Sep 27, 2016 at 8:16
  • Too bad the crawler functions (Add/Update) do not provide a return value - otherwise it would have been easier to override some index functions...
    – Gatogordo
    Sep 27, 2016 at 8:36

To do this you would need to hook into the publish:itemProcessed event and build a message queue of items that match your template - you could do the message queue many ways, SQL Server, RabbitMQ etc..

Then in the indexing:end if you are on the correct delivery index (sitecore_web_index or a custom one), you can then process any items in the queue you have built. Clear the caches for those items and rebuild from the index or just let the next request build the cache.

I have done this before - you want to make sure that in the publish:itemProcessed event you exit very quickly if the template does not match and that your code runs fast so it does not slow down the publish process too much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.