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

set expires header corresponding to maxAge #1651

Merged
merged 2 commits into from
Apr 22, 2018

Conversation

RedSparr0w
Copy link
Member

@RedSparr0w RedSparr0w commented Apr 16, 2018

closes #1650
currently when using ?maxAge= the cache-control header is set correctly but the expires header is always set to the current time.

This PR:

Cache-Control: max-age=3600
Date: Mon, 16 Apr 2018 21:57:47 GMT
Expires: Mon, 16 Apr 2018 22:57:47 GMT

Current:

cache-control: max-age=3600
date: Mon, 16 Apr 2018 21:55:33 GMT
expires: Mon, 16 Apr 2018 21:55:33 GMT

@shields-ci
Copy link

shields-ci commented Apr 16, 2018

Messages
📖

✨ Thanks for your contribution to Shields, @RedSparr0w!

Generated by 🚫 dangerJS

Copy link
Member

@platan platan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me. Would you like to add some tests?

@RedSparr0w
Copy link
Member Author

Probably a good idea, although i'm really not sure how to test the headers.


Also according to RFC 2616 on W3

The max-age directive takes priority over Expires, so if max-age is present in a response, the calculation is simply:
    freshness_lifetime = max_age_value
Otherwise, if Expires is present in the response, the calculation is:
    freshness_lifetime = expires_value - date_value

So this PR may actually be pointless?

@RedSparr0w
Copy link
Member Author

Have added some tests if you could please give it another look over @platan

@ale5000-git
Copy link

ale5000-git commented Apr 20, 2018

So this PR may actually be pointless?

It may be pointless in a perfect world but different implementations take different approach, there will always be someone not following the spec or maybe also not supporting Cache-Control but supporting Expires.

@RedSparr0w RedSparr0w merged commit 8fda86f into badges:master Apr 22, 2018
@ale5000-git
Copy link

Deploy status

@RedSparr0w RedSparr0w deleted the cache-control branch January 21, 2019 03:11
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 this pull request may close these issues.

Problem with maxAge parameter
4 participants