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

Badges aren't updating due to being cached on GitHub. #3323

Closed
MikeHart85 opened this issue Nov 27, 2017 · 12 comments
Closed

Badges aren't updating due to being cached on GitHub. #3323

MikeHart85 opened this issue Nov 27, 2017 · 12 comments
Labels
Bug A bug

Comments

@MikeHart85
Copy link

Details

Probably affects everyone that uses badges. At least on GitHub.

Our RTFD badge has been showing "failing" for days now, even though the docs build successfully.

Appears to be happening because GitHub has the image cached on its own domain.

Had a look at HTTP headers:

https://readthedocs.org/projects/lewis/badge/?version=latest

302 Redirect
Cache-Control: "no-cache, no-store, must-revalidate, max-age=0"

https://media.readthedocs.org/static/projects/badges/passing.svg

200 OK
Cache-Control: "max-age=604800"

Seems likely that GitHub is ignoring the Cache-Control of the initial URL and respecting the Cache-Control of the redirect target... which means the badge will be cached for 604800 seconds == 7 days.

Related issues: #1612 and #3000.
Appears fixed in: 8c37801#diff-5d1a334650edab756ce4cdf8c531111e
Likely reintroduced by: 91f6c08#diff-5d1a334650edab756ce4cdf8c531111e

Note the latter commit was on Aug 17. Two new comments against #1612 since then complain that the problem still exists. Comments dated Aug 21 and Oct 31.

Expected Result

Badge should update when build status changes.

Actual Result

Badge doesn't update because it is cached.

@RichardLitt RichardLitt added the Bug A bug label Nov 27, 2017
@ericholscher
Copy link
Member

So we need to add the max age back in?

@ericholscher
Copy link
Member

I believe I can set this on nginx just for the badges directory, and it should fix it.

@ericholscher
Copy link
Member

Did some testing. Does this look like it will fix it?

HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Fri, 08 Dec 2017 15:22:16 GMT
Content-Type: image/svg+xml
Content-Length: 790
Connection: keep-alive
Last-Modified: Friday, 08-Dec-2017 15:22:16 GMT
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
X-Deity: web01
Access-Control-Allow-Origin: *
X-Served: Nginx
Accept-Ranges: bytes

@dsuess
Copy link

dsuess commented Dec 14, 2017

I still see the project in our project

Here is what the github people say: github/markup#224

@ericholscher
Copy link
Member

Believe this should be fixed.

@piccolbo
Copy link

I can see it right now on my project:
https://github.com/piccolbo/altair_recipes

Badge is red but docs are right there in place. Last failed build close to two days old. Loading the image separately (per rst file) results in a green badge. The image appears to be cached by github per address bar if I open the image alone. Other badges are moving along just fine.

@piccolbo
Copy link

Never mind I see there's a three days old fix. Hopefully it will kick in at some point.

@davidfischer
Copy link
Contributor

I believe we have this corrected. However, we're waiting for two things:

  • Firstly we need github to pick up the change with their intermediate proxy. I assume this will happen relatively soon.
  • Secondly, users may need to flush their cache as github sent down the badge with 1 year cache headers.
$ curl -IL https://readthedocs.org/projects/pip/badge/
HTTP/1.1 200 OK
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Length: 0
Content-Type: image/svg+xml
Content-Language: en
Expires: Thu, 30 Aug 2018 22:05:33 GMT
Last-Modified: Thu, 30 Aug 2018 22:05:33 GMT
Vary: Accept-Language, Cookie
Server: nginx/1.14.0 (Ubuntu)
X-Frame-Options: DENY
X-Deity: web04
Date: Thu, 30 Aug 2018 22:05:32 GMT

@piccolbo
Copy link

Will keep an eye on it thanks.

@sjspielman
Copy link

+1 This is ongoing. Any fixes?

@ericholscher
Copy link
Member

We are still setting the cache headers, do you have more information about this issue?

@webappsforindustry
Copy link

Add cache-control=no-cache as a parameter to your URL. per example:
Old URL = https://tryhackme-badges.s3.amazonaws.com/secutest.png?style=flat
New URL = https://tryhackme-badges.s3.amazonaws.com/secutest.png?style=flat&cache-control=no-cache

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

No branches or pull requests

8 participants