Events | laravel-responsecache | Spatie

 SPATIE

  Laravel Response Cache
=========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-responsecache](https://spatie.be/docs/laravel-responsecache/v8)  Basic-usage  Events

 Version   v8

 Other versions for crawler [v8](https://spatie.be/docs/laravel-responsecache/v8)

- [ Introduction ](https://spatie.be/docs/laravel-responsecache/v8/introduction)
- [ Support us ](https://spatie.be/docs/laravel-responsecache/v8/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-responsecache/v8/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-responsecache/v8/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-responsecache/v8/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-responsecache/v8/changelog)
- [ About us ](https://spatie.be/docs/laravel-responsecache/v8/about-us)

Basic usage
-----------

- [ Caching responses ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/caching-responses)
- [ Flexible caching (SWR) ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/flexible-caching)
- [ Preventing caching ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/preventing-caching)
- [ Clearing the cache ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/clearing-the-cache)
- [ Using tags ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/using-tags)
- [ Events ](https://spatie.be/docs/laravel-responsecache/v8/basic-usage/events)

Advanced usage
--------------

- [ Custom cache profiles ](https://spatie.be/docs/laravel-responsecache/v8/advanced-usage/custom-cache-profiles)
- [ Creating a replacer ](https://spatie.be/docs/laravel-responsecache/v8/advanced-usage/creating-a-replacer)
- [ Customizing the serializer ](https://spatie.be/docs/laravel-responsecache/v8/advanced-usage/customizing-the-serializer)
- [ Customizing the hasher ](https://spatie.be/docs/laravel-responsecache/v8/advanced-usage/customizing-the-hasher)
- [ Configuration ](https://spatie.be/docs/laravel-responsecache/v8/advanced-usage/configuration)

 Events
======

###  On this page

1. [ ResponseCacheHitEvent ](#content-responsecachehitevent)
2. [ CacheMissedEvent ](#content-cachemissedevent)
3. [ ClearingResponseCacheEvent ](#content-clearingresponsecacheevent)
4. [ ClearedResponseCacheEvent ](#content-clearedresponsecacheevent)
5. [ ClearingResponseCacheFailedEvent ](#content-clearingresponsecachefailedevent)

There are several events you can use to monitor and debug response caching in your application.

ResponseCacheHitEvent
-----------------------------------------------------------------------------------------------------------------------

`Spatie\ResponseCache\Events\ResponseCacheHitEvent`

Fired when a cached response is found and returned. The event receives the `Request` object, the cache age in seconds, and the tags used.

CacheMissedEvent
--------------------------------------------------------------------------------------------------------

`Spatie\ResponseCache\Events\CacheMissedEvent`

Fired when no cached response is found for the request. The event receives the `Request` object.

ClearingResponseCacheEvent
--------------------------------------------------------------------------------------------------------------------------------------

`Spatie\ResponseCache\Events\ClearingResponseCacheEvent`

Fired when the response cache is about to be cleared.

ClearedResponseCacheEvent
-----------------------------------------------------------------------------------------------------------------------------------

`Spatie\ResponseCache\Events\ClearedResponseCacheEvent`

Fired after the response cache has been successfully cleared.

ClearingResponseCacheFailedEvent
--------------------------------------------------------------------------------------------------------------------------------------------------------

`Spatie\ResponseCache\Events\ClearingResponseCacheFailedEvent`

Fired when clearing the response cache fails.
