Some data retrieval or processing tasks performed by your application could be CPU intensive or take several seconds to complete. When this is the case, it is common to cache the retrieved data for a time, so it can be retrieved quickly on subsequent requests for the same data.
Slim uses the optional standalone slimphp/Slim-HttpCache PHP component for HTTP caching. You can use this component to create and return responses that contain
Last-Modified headers that control when and how long application output is retained by client-side caches. You may have to set your php.ini setting “session.cache_limiter” to an empty string in order to get this working without interferences.
- Slim 4 - HTTP Caching (eBook Vol. 2)
The cached data is usually stored in a very fast data store such as Memcached or Redis. Thankfully, the laminas/laminas-cache and symfony/cache components provides a PSR-6 and PSR-16 compliant API for various cache backends, allowing you to take advantage of their blazing fast data retrieval and speed up your web application.
- Slim 4 - Symfony Cache (eBook Vol. 2)
- Slim 4 - Redis (eBook)
- Slim 4 - Memcached (eBook)