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 Cache-Control: no-cache for redirects to badges #1653

Merged
merged 3 commits into from
Sep 14, 2015

Conversation

gregmuellegger
Copy link
Contributor

The badges provided by readthedocs.org are created using shields.io, using a redirect. We did not have the Cache-Control set on those redirects which might make GitHub cache the badges too aggressively when they are used in a README file.

The github/markup#224 issue explains that we need to set the Cache-Control and ETag header to disable caching for the badges. However we are not serving the badges, but redirecting, so we just need to try out whether a Cache-Control header on the redirect has any effect. I did a quick google search but was not able to find if it's valid to set ETag headers on a redirect. I think it's nonsense as the body of a redirect response is usually empty.

Related #1612

@@ -119,7 +120,8 @@ def _badge_return(redirect, url):


# TODO remove this, it's a temporary fix to heavy database usage
@cache_page(60 * 30)
@cache_page(60 * 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just get rid of this caching now, I've fixed the index misses that were bogging down the database.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

agjohnson added a commit that referenced this pull request Sep 14, 2015
Set Cache-Control: no-cache for redirects to badges
@agjohnson agjohnson merged commit b893883 into master Sep 14, 2015
@agjohnson agjohnson deleted the badge-cache-control branch September 14, 2015 16:06
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.

2 participants