Skip to main content

Posts

Showing posts with the label The hidden SetCacheHeaders Middleware

Laravel: The hidden SetCacheHeaders Middleware

There are a lot of useful middlewares already registered inside Laravel, like the   authentication mechanisms ,   authorization , a   throttler , and even the one responsible to make   route model binding   possible. Practically, your middleware needs are covered. Except for one. There is one middleware that doesn’t get the spotlight in Laravel. It’s called   SetCacheHeaders , which is aliased as   cache.headers . And, there is no mention of it in the documentation. I’m not joking, guys: Who, when, how? A quick look around in the   api documentation   and the   source repository   says this middleware was added   added before christmas of 2017   after   a lengthy discussion , but it's a mystery why nobody has talked about it since it’s seems very…   convenient . In any case, after making this article, my   PR to the documentation   was accepted, so   you should find it now in the documentation . A ...