Caching and related Entries
This sounds like a bug, and I think I know why. Can you try changing the {% set entryCount ... line to this?

{% set entryCount = craft.entries.relatedTo(category.id).total() %}