Spatie Laravel Response Cache

How do you cache efficiently in Laravel? Trying to figure out an efficient way to serve data using the least amount of resources is always a challenge to face when scaling. How much of the data to process in the front vs back end. When to cache and how to handle the scope of what to cache.

I’ve found various cache solutions that handle problems:

Each has it’s own usability, speed, performance that works or doesn’t. The latest one I’ve tried is Spatie’s Laravel Response Cache. It caches the response of successful get requests per user and serves it when the request is hit again. It’s easy to use and made my app significantly faster within the cached period. 10/10

Some tips:

  • Publish the config to change how long the cache is stored by default
  • To enable cache on ajax you need to create your own cacheprofile

Both points should be in the doc but isn’t explicit.

Leave a Comment