Currently once in every few requests (or even in every request) storefront call special platform API to understand was something changed or not. Now, with webhooks, storefront may just subscribe to them to understand that it need to invalidate cache. This approach should increase performance.
How to implement
Step 1. Install Webhooks module
Step 2. Create webhook endpoint in Storefront Application
Webhook notifications are sent in the background via a POST request with JSON serialized event data to the specified URL.
- Create a new Api Controller
- Add dependency from IStorefrontMemoryCache
- Add a new POST Method to read incoming events
Step 3. Implement Cache invalidation logic
- Parse Incoming Event from JSON. Example of notification, sent on Order creation
- Call Cache Invalidation method
Step 4. Configure a new endpoint in WebHook module
- Go to Admin
- Configure a new webhook endpoint