57

I serve some of my files from my Github pages account. But when I check my "js" files' headers, I saw following:

Last-Modified:Sun, 10 Feb 2013 14:00:46 GMT 
Expires:Sun, 10 Feb 2013 14:13:23 GMT
Cache-Control:max-age=600

This file was commited 14 days ago. But I don't plan these files so frequent. So I need to make much bigger max-age value and change Last-Modified value to last commited date.

Is it possible to change headers of Github pages?

Samyak Bhuta
  • 1,226
  • 7
  • 20
trante
  • 30,976
  • 45
  • 174
  • 260
  • http://stackoverflow.com/questions/12556593/determining-a-page-is-outdated-on-github-pages http://stackoverflow.com/questions/3956455/html-5-cache-manifest-vs-etags-expires-or-cache-control-header/ – trante Feb 17 '13 at 18:22

4 Answers4

66

I asked this to Github admins, and they told me that "it is not possible" to change headers. They added this issue to wishlist.

trante
  • 30,976
  • 45
  • 174
  • 260
  • 1
    Still not possible. Github doesn't want to add possibility to modify Github Pages HTTP headers. The current only workaround is to use HTML `meta` tags. – Binyamin Mar 13 '18 at 18:27
19

The answer is no, however we can stimulate html header on html pages using <meta http-equiv> tag.

<meta http-equiv="last-modified" content="Sun, 10 Feb 2013 14:00:46 GMT " />
<meta http-equiv="cache-control" content="Private" />
<meta http-equiv="Expires" content="600" />

You can embed these snippets into the HTML page.

Richie Bendall
  • 3,783
  • 2
  • 24
  • 36
tamyiuchau
  • 191
  • 1
  • 5
5

This is for all the people still having this problem and coming here from google.

Had the same problem recently. Actually it is possible if you are stubborn enough and wish to use some extra, third party services. What you need to do, is to use free tier heroku app with custom nginx buildpack. This buildpack would work as a proxy pass, which can add/remove HTTP headers as you please.

You will lose GitHub CDN though, so it may be good idea to leverage another service - cloudflare to do just that (and SSL as a bonus).

I wrote an article with detailed setup how to do this, if somebody is intereseted: https://www.rzegocki.pl/blog/custom-http-headers-with-github-pages/ - the setup is pretty cumbersome but it works.

Ajgon
  • 81
  • 1
  • 4
5

It's currently not possible in Github Pages. You can use Github with Netlify. They let you change headers. They also have nice features like forms, prerendering and more. Which all are missing in Github Pages.

Howdy
  • 465
  • 7
  • 12
  • 2
    Comparative Breakdown of GitHub Pages vs. Netlify - [www.netlify.com/github-pages-vs-netlify](https://www.netlify.com/github-pages-vs-netlify/) – Alex Klaus May 24 '19 at 05:43