slimphp / Slim-HttpCache

Slim Framework HTTP cache middleware and service provider
MIT License
114 stars 26 forks source link

Body is still sent on 304 #54

Open JimTools opened 6 months ago

JimTools commented 6 months ago

There is odd behaviour around cache hits, the whole idea of the 304 status is to reduce data transmission if the browser/client has data which is still accurate.

I've noticed that the response body isn't truncated defeating the purpose, technically this isn't a bug nor an implementation issue I still think it's incorrect behaviour.

While the developers can work around this by handling it in their projects, I feel like this package should handle this.

RFC-9110 MDN 304

odan commented 2 months ago

I think this could be handled very easy with a custom middleware. Check for the response status code == 304 and return a response with an empty response body.