Github pages, HTTP headers

末鹿安然 提交于 2019-12-18 10:32:38

问题


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?


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/14798589/github-pages-http-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!