github page blog from jekyll needs force reload to show changes with posts

1.4k views Asked by At

I'm learning a jekyll with github pages. When i create a new post (whatever how - locally and commit to github or online via github page) i need to force reload (ctrl+r) my page to see changes. Is it normal?

my repository url is here

2

There are 2 answers

1
David Jacquel On

As Github pages content has http response headers like Cache-Control:max-age=600 and Expires:Wed, 10 Jun 2015 16:30:25 GMT (a date ten minutes latter), the only way to avoid page caching is to setup your browser not to cache.

If your read carefully this answer about http-equiv meta (read HTML meta tags vs HTTP response headers paragraph), you will understand that, in your case, http-equiv meta are useless.

And this cache has nothing to do with Jekyll but with github pages servers setup. A 10 minutes cache on a personal blog is not that big. A regular user will not need a refresh every 30 seconds.

And as a developer you are not supposed to develop on you production server, but on a development one, where you can specifically setup your server.

0
Erik Gillespie On

That's just browsers doing their thing. If you use the published: false Front Matter to work on drafts then you can conditionally disable caching using the following snippet in the <head> section of your post layout:

<% if page.published != true %>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<% endif %>

At the top of your work-in-progress:

---
layout: post
title: My New Article
published: false
---

When you want to publish for real, just remove the published: false YAML or set it to true.