Working on Web SDL 8.5, I am dealing with an issue that service cache is not aware of new publication. As such, when a query is executed, the results do not contain the newly published dynamic components. Investigation of the broker database shows that the contents have been published successfully. Also, unpublishing the content occasionally updates the cache and executing the same query to retrieve the dynamic components returns the updated data, but it is not a consistent behavior. I am wondering how I can resolve this issue and make the cache service publish and unpublish aware?
You need to configure cache invalidation messaging - see the documentation on this topic: https://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-7E728735-073B-4827-AABE-B45592CFF36D
With this in place, the deployer will send messages to the Content Services invalidating whatever has just been published.