Skip to content

Implement valueOf to compare CacheControl objects #15

@davidbarratt

Description

@davidbarratt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions