134

I am just wondering how long does it take for GitHub page to show the new items that I have added to the repository.

I changed index.html but after 10 minutes it still showed up the previous page...

zx8754
  • 52,746
  • 12
  • 114
  • 209
MYjx
  • 4,157
  • 9
  • 38
  • 53
  • If your repo is public, and you care to share a link, I can take a look at it if you are still having trouble to see if there is any misconfiguration. – Joel Glovier Jul 21 '14 at 18:12
  • Maybe it's a timezone issue. Check this, http://stackoverflow.com/a/35388975/1080041 . – Hong Apr 20 '16 at 13:28

4 Answers4

139

The first time you generate your site it will take about 10 minutes for it to show up. Subsequent builds take only seconds from the time you push the changes to your GitHub repository.

However, depending on how your have your domain configured, there may be extra time for the CDN cache to break.

Note: using a subdomain, such as yourproject.github.io is the recommended domain setup, but does mean page builds take longer to show up since it has the benefit of using the GitHub CDN.

Joel Glovier
  • 7,469
  • 9
  • 51
  • 86
  • 3
    it takes ages sometimes if you use custom, how much of a benifit is the cdn? – SuperUberDuper Dec 17 '16 at 12:23
  • 30
    @SuperUberDuper the CDN will always update when you push new files. If you want to test it (or break a cache) you can append a query string like `myfile.jpg?ver=123` and every time you update the string the cache will bust, and you can verify that the CDN is updating. – Joel Glovier Dec 19 '16 at 14:10
  • 3
    @SuperUberDuper also, if you are not seeing your files update, another explanation could be that your build is broken. Did you receive an email from GitHub Pages saying your build is failing? Configuring Travis CI on your repo is a great way to track failing builds as well. – Joel Glovier Dec 19 '16 at 14:12
  • 2
    @JoelGlovier Post the cache-buster as an answer and I'll upvote :) . Worked like a charm! – cxw Mar 15 '18 at 17:38
  • How long does the CDN cache for? – Ben McCann Feb 16 '19 at 02:02
  • GitHub update that you can put only your project name, now it's not mandatory like yourproject.github.io . after go to setting>pages change setting as per our requirement. – Pankaj Sajekar Apr 28 '23 at 06:11
34

Github pages are cached with CDN. As explained by JoelGlovier in comments, you can still have the latest version of your pages by appending a version in the query string such as https://username.github.io/awesome-repo/?version=f36af92 so that you won't get a cached version of your page.

Marco Di Francesco
  • 35
  • 1
  • 4
  • 14
asidis
  • 1,374
  • 14
  • 24
  • 2
    I tried the version of my latest commit, but still getting the stale version of my file. Does it still work for you? – Steven Zhou Mar 05 '20 at 23:18
  • 1
    @StevenZhou you can put anything you want to avoid the cache but it must be something that you did not use yet – asidis Mar 06 '20 at 08:21
  • I did put random text and still got nothing – emanuel sanga May 01 '20 at 20:45
  • @emanuelsanga did you add the random text in the query string? – asidis May 02 '20 at 11:12
  • 1
    Can someone confirm if this works? I have tried and I am not getting the most recent version and still a delay. e.g ` https://myrepo.github.io/123/test.html?version=f36af932343df` – Kex Jul 19 '20 at 15:44
  • did you get around to sorting this out? – Brofessor Apr 01 '21 at 10:45
  • I just tested it today: get the page(so that my browser cache the original version of my page), edit my repo(edit, commit, push), get the page again (still the old one, cannot see my change), get the page with ?v=test at the end and I manage to have my change visible (by appending ?v=test or v=anything I forced my browser to not reuse the cache) – asidis Apr 05 '21 at 21:56
30

Github also has a deployment page: https://github.com/<user>/<repo>/deployments that lists the deployments and the time they were deployed.

Choose github-pages from the environments drop-down list.

This helps to know if your latest git push was deployed at all.

user650654
  • 5,630
  • 3
  • 41
  • 44
  • Do you happen to know how frequent does the deployment happen? Is this the CDN deployment? Can we force it to flush the cache? – Steven Zhou Mar 05 '20 at 23:21
  • I've seen the changes being pushed almost immediately after a push to the repo. Although, [this github guide](https://guides.github.com/features/pages/) says the SLA is 10 minutes. – user650654 Mar 06 '20 at 01:14
  • @lone_coder, it's working for me. Are you signed in? Do you own the repo? – user650654 Oct 07 '20 at 14:24
10

Github pages are cached with CDN.So the user has to clear the site cache everytime to load new changes.To overcome this you can use meta tags in the HTML code, they will load the webpage without caching.Include this in your index.html file.

<meta http-equiv='cache-control' content='no-cache'> 
<meta http-equiv='expires' content='0'> 
<meta http-equiv='pragma' content='no-cache'>

Using this you won't get a cached version of your page.