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

Implement valueOf to compare CacheControl objects #15

Open
davidbarratt opened this issue Sep 1, 2018 · 1 comment
Open

Implement valueOf to compare CacheControl objects #15

davidbarratt opened this issue Sep 1, 2018 · 1 comment

Comments

@davidbarratt
Copy link

davidbarratt commented Sep 1, 2018

It would be really helpful if the CacheControl object implemented a custom valueOf in order to compare CacheControl objects.

Use-case: I'm making a bunch of HTTP requests to various 3rd party servers and combining them into a single response. These requests have various Cache-Control headers, but I'd like my API to respond with the most restrive (i.e. least cachable) of the lot.

For instance, if I have a set like this:

max-age: 600, public
max-age: 300, public

I'd need the second of the two. But if I have a set like this:

private
max-age: 600, public
max-age: 300, public

I would need the first one.

I realize it might be difficult to translate the Cache-Control into a number, but I think it's ok if some options produce the same number (i.e. private could be -1 and immutable could be 100000000 or something). Or perhaps different options have different weights?

@tusbar
Copy link
Owner

tusbar commented Sep 27, 2018

Hey @davidbarratt,

This wouldn’t be a bad idea. I don’t want this repo to hold too many features besides parsing though but this could be light enough.

If you want to take a stab at it, be my guest. :)

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

No branches or pull requests

2 participants