Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Http Cache Laravel Package

slim/http-cache

A PSR-15 middleware that adds HTTP caching to Slim 4 apps, handling ETag/Last-Modified conditional requests, Cache-Control headers, and filesystem response caching to cut bandwidth and speed up repeat visits.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Response-caching roadmap for read-heavy endpoints. Decides whether our GET APIs return Cache-Control, Expires, ETag, and Last-Modified headers and honor If-None-Match / If-Modified-Since with a 304 Not Modified — the cheapest latency and bandwidth win available before we invest in a CDN, Redis, or an edge tier.
  • Build vs. buy on conditional-request logic. The alternative is hand-rolling entity-tag generation and freshness/validation semantics in every service. Buying a small, standards-based middleware removes a class of subtle bugs (weak vs. strong ETags, Vary, 304 body stripping) that are easy to get wrong and hard to test.
  • Client and integration contract decisions. Once we commit to conditional requests, mobile clients, reverse proxies, and CDN configs can be designed around them. This is a contract decision, not just an implementation detail — it affects SDK guidance and API documentation.
  • Scope/stack decision — flag this first. Despite the brief, slim/http-cache is not a Laravel package. It is PSR-7/PSR-15 middleware (plus a Pimple service provider for Slim 3) for the Slim Framework. For a Laravel codebase the decision it supports is "use a Laravel-native equivalent" (spatie/laravel-responsecache, Symfony's HttpCache, or framework middleware), with this package serving only as a reference implementation of the header semantics. For a Slim-based microservice or internal API in our estate, it is directly adoptable.
  • Buy-signal caveat. 116 stars, 0 dependents, an opportunity score of ~42, and an overall score of 2.33 tell us this is a low-adoption, narrow-audience component. That is not disqualifying for a ~few-hundred-line middleware from the official slimphp org under MIT — but it does mean we, not the community, will be the ones finding the edge cases.

When to Consider This Package

Adopt when all of the following hold:

  • The service is genuinely on Slim 3 or Slim 4 (PSR-15 middleware pipeline); it will not drop into Laravel, Symfony, or a plain PSR-7 app without glue.
  • The workload is GET-heavy and cacheable: catalog reads, config/feature-flag payloads, public reference data, static-ish JSON.
  • We control representation determinism, so ETags are stable across requests, and we can correctly set Vary for anything content-negotiated.
  • We want conditional requests at the application layer so both direct clients and an upstream CDN/proxy benefit, without standing up new infrastructure.

Look elsewhere when:

  • The stack is Laravel. Use spatie/laravel-responsecache, Laravel's own cache middleware, or Symfony HttpCache/HttpKernel — anything else means re-implementing the integration and owning it forever.
  • You need storage or invalidation. This package only emits and validates headers; it does not cache response bodies, does not tag, and does not purge. If the requirement is "cache the rendered response and invalidate on write," this is the wrong tool — you need response caching with a backing store, tag-based invalidation, or a CDN/Varnish layer.
  • Responses are per-user or personalized. Authenticated, session-scoped, or permission-filtered payloads are a cache-poisoning risk; without disciplined Vary/private handling the middleware creates more risk than it removes.
  • You need modern freshness semantics — stale-while-revalidate, stale-if-error, surrogate keys. Reach for a CDN or dedicated cache layer instead.
  • Long-horizon support matters and no one owns it. Single-maintainer risk on a 0-dependent package means we should be prepared to vendor or fork (MIT makes that cheap) or to simply inline the header logic.

How to Pitch It (Stakeholders)

To executives: This is a small, MIT-licensed middleware from the official Slim project that lets our read APIs answer "has this changed?" with a cheap 304 instead of a full payload. It requires no new infrastructure, cuts bandwidth and mobile latency on our most-repeated GET calls, and is roughly a few hundred lines we can read, test, and fork if needed. The honest framing: the wins are real but incremental, and it only applies to services built on Slim — for our Laravel services we would standardize on the Laravel-native equivalent and treat this as the reference pattern. It is a tactical optimization, not a platform investment, and it should not be sold as a substitute for a CDN.

To engineering: Thin PSR-15 middleware (PSR-7 for Slim 3) that adds Cache-Control, Expires, ETag, Last-Modified and returns 304 on conditional requests; it handles header semantics only — no response storage, no invalidation, no tagging — so pair it with explicit cache policy per route and careful Vary handling for anything personalized. Low community adoption (116 stars, 0 dependents), so budget for reading the source, adding our own test coverage on ETag stability and 304 body handling, and accepting that we may vendor it. Adopt on Slim services with clearly cacheable GET endpoints; do not introduce it into Laravel, and do not use it as a stand-in for a CDN or response cache.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings