Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping an HTTP client call and using the cache-control header value to cache the response #25

Closed
pfortin-urbn opened this issue May 1, 2024 · 2 comments · Fixed by #26

Comments

@pfortin-urbn
Copy link

As the title indicates, I have a need for the wrapped method to define the cache refresh time of the data that is being returned.

If I make an http call to get a config item that rarely changes - the server might respond with the header: Cache-Control: MAX-AGE=900. so now I want to cache that data for 900 seconds, but if the code of the server changes to respond with Cache-Control: MAX-AGE=1500. I don;t want to change my code I want it to adapt to the new cache-control header.

There may be other patterns in which this type of caching could be used.

Do you have a method to handle this if not I have a rough POC of a change to your wrapper that could work that I'd be willing to provide if you are interested.

zmumi added a commit that referenced this issue May 3, 2024
…e/update time control (different settings per entry).

* Minor fix for contribution guide (after migration, Travis was still mentioned instead of GitHub Actions).
@zmumi zmumi closed this as completed in #26 May 3, 2024
zmumi added a commit that referenced this issue May 3, 2024
…e/update time control (different settings per entry). (#26)

* Minor fix for contribution guide (after migration, Travis was still mentioned instead of GitHub Actions).
@zmumi
Copy link
Member

zmumi commented May 3, 2024

@pfortin-urbn take a look at the example I just added and let me know if such a solution looks suitable for your use-case
https://memoize.readthedocs.io/en/latest/readme_link.html#openness-to-granular-ttl

@pfortin-urbn
Copy link
Author

@zmumi I think that might do it - let me do some local testing and I'll get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants