Currently I use Jekyll to generate static site and host it on my GitHub pages. After I first setup the basic environment of Jekyll and pushed local changes to the remote master branch, I thought everything was fine and sitted back to enjoy this convinence brought by Jekyll. However, after I added a new blog post and push changes to master branch, my GitHub pages didn't get updated. There was only the initial "Hello world" post I added before.
Automatic Regeneration of Jekyll
During the development process, I use jekyll serve
to serve a local site. Whenever I modifies a file, the content of the site will be regenerated by Jekyll automatically. This is called automatic regeneration, something like hot reloading.
Solution
However, when in production environment(hosted on GitHug pages), the changes may not take effect due to browser caching, squid proxy server caching, etc. After checking this issue, I decided to added the following lines at the front of home.html
:
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
Still Confused
First of all, I only added the line of code in home.html
, hoping it would only disable caching for the home page. However, I used Chrome DevTools to inspect the network response and found that caching is disabled for every page of my GitHub pages. It is more strange that when I tried after a while, I found that every page was cached! The responses of every page came with a header: cache-control: max-age=600
.
I also tried another way: Custom WEBrick Headers. I added the following code into the file _config.yml
:
webrick:
headers:
Cache-Control: no-cache
However, it seemed not working. Such frustration! Looking forward to a final solution...
网友评论