Caching

Webhooks

TheShop uses a pulling system (webhooks) to inform the fronstore about a content change. For each action, you can set up this webhook in settings.

After the webhook URL for your frontstore is present, and changes in administration were made, TheShop sends a request to defined webhook URL.

For example, theshopdev/frontstore uses Cache::rememberForever method to cache static content, so homepage categories are cached forever to reduce API loads.

Frontstore

On the frontstore side, there is a route called /reset-cache, which, by default, accepts a token parameter that you can set up anyhow you want – in .env file, it is provided as CACHE_RESET_TOKEN, to keep this channel secured.

This route checks for a token. If an incoming webhook contains a valid token, cache on the frontstore is flushed. If it does not contain a valid token, the response to server is 400 - Bad request.

This endpoint is a basic implementation and you can develop it in your on way. For example, flush only desired contents based on the webhooks you define.

Last updated