美文网首页
Jekyll page cache control

Jekyll page cache control

作者: _Derek_H_ | 来源:发表于2018-08-31 19:47 被阅读0次

    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...

    相关文章

      网友评论

          本文标题:Jekyll page cache control

          本文链接:https://www.haomeiwen.com/subject/yluewftx.html