Improve cache invalidation with new webhooks module

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.

1 Like

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.

  1. Create a new Api Controller
  2. Add dependency from IStorefrontMemoryCache
  3. Add a new POST Method to read incoming events

Step 3. Implement Cache invalidation logic

  1. Parse Incoming Event from JSON. Example of notification, sent on Order creation
  2. Call Cache Invalidation method

Step 4. Configure a new endpoint in WebHook module

  1. Go to Admin
  2. Configure a new webhook endpoint
1 Like