victorspringer / http-cache

High performance Golang HTTP middleware for server-side application layer caching, ideal for REST APIs
https://godoc.org/github.com/victorspringer/http-cache
MIT License
339 stars 63 forks source link

Implement writeExpiresHeader option for client #14

Closed man90es closed 9 months ago

man90es commented 2 years ago

This pull request adds an option to automatically add an Expires header to all responses. This will let the client (e.g. frontend) to know the exact time when the server cache will expire and utilise disk cache to reduce the number of requests. The option is off by default so it should be completely backward compatible with previous library versions.

davitovmasyan commented 1 year ago

@octoman90 do you think it is worth adding Cache-Control header as well?

davitovmasyan commented 1 year ago

@victorspringer are you going to do a review/merge this? or do you have plans to add cache-related response headers?

man90es commented 1 year ago

@davitovmasyan, this functionality can totally be achieved by setting a combination of Cache-Control and Age headers: this approach would even offer some additional features that Expires header doesn't have. But I don't really need them in my project, so I went for the simplest solution.

I hope this PR gets merged one day, along with the other one I made. Until then, I'm using my own fork in said project by having replace github.com/victorspringer/http-cache => github.com/octoman90/http-cache v0.0.0-20220627112407-5a1d73af7fc5 in go.mod

cute-angelia commented 1 year ago

good idea

victorspringer commented 9 months ago

LGTM. Sorry for the inactivity guys, I'm merging this PR. @man90es thanks for the contribution!